Skip to content

Instantly share code, notes, and snippets.

@ChrisBeeley
Created April 3, 2020 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisBeeley/cfddc35235f6119c326d7f70e8ad9120 to your computer and use it in GitHub Desktop.
Save ChrisBeeley/cfddc35235f6119c326d7f70e8ad9120 to your computer and use it in GitHub Desktop.
Test to see how app.R behaves the first time it runs and on subsequent runs
library(shiny)
library(tidyverse)
library(DT)
load("ae_attendances.RData")
Sys.sleep(10)
# filter to random 10 Trusts with a decent amount of data in
sample_trusts <- ae_attendances %>%
group_by(Name) %>%
count() %>%
ungroup() %>%
filter(n > 50) %>%
sample_n(10) %>%
pull(Name)
ae_attendances <- ae_attendances %>%
filter(Name %in% sample_trusts)
ui <- fluidPage(
# Application title
titlePanel("A and E data"),
sidebarLayout(
sidebarPanel(
selectInput("trust",
"Select Trust",
choices = unique(ae_attendances$Name))
),
mainPanel(
DT::dataTableOutput("trustTable")
)
)
)
server <- function(input, output) {
output$trustTable <- DT::renderDataTable({
ae_attendances %>%
filter(Name == input$trust)
})
}
# Run the application
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment