-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
44 lines (38 loc) · 1.17 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
library(shiny)
library(plotly)
library(dplyr)
# UI -----------------------------------------------------------------------
ui <- fluidPage(
titlePanel("COVID-19 Counts by Age Group"),
sidebarLayout(
sidebarPanel(
selectInput("district", "Select District:",
choices = c("Alexandria", "Arlington", "Fairfax", "Loudoun", "Prince William"))
),
mainPanel(
plotlyOutput("plot"),
br(),
tableOutput("table")
)
)
)
# Server -------------------------------------------------------------------
server <- function(input, output, session) {
output$plot <- renderPlotly({
plot <- switch(input$district,
"Alexandria" = alexandria_plot,
"Arlington" = arlington_plot,
"Fairfax" = fairfax_plot,
"Loudoun" = loudoun_plot,
"Prince William" = pw_plot)
plot
})
output$table <- renderTable({
combined_data %>%
filter(district == input$district) %>%
group_by(variable) %>%
summarize(total = sum(count))
})
}
# Shiny App ----------------------------------------------------------------
shinyApp(ui, server)