Skip to content

Instantly share code, notes, and snippets.

@ChrisBeeley
Created Apr 3, 2020
Embed
What would you like to do?
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