Commit 22a72fd9 authored by Gavin Lee's avatar Gavin Lee
Browse files

Auto-saving for lee.gavin.k on branch master from commit 144029af

parent 144029af
Pipeline #45767 passed with stage
in 30 seconds
enableBookmarking(store = "url")
......@@ -123,8 +123,8 @@ options(DT.options = list(
language = list(search = "Filter:")
))
server <- function(input, output, session) {
server <- function(input, output, session) {
output$last_updated <- renderText({
# Get latest dcf update date
dcf <- read.dcf("rsconnect/shinyapps.io/renkulab/COVID-19-Epidemic-Forecasting.dcf")
......@@ -260,17 +260,21 @@ options(DT.options = list(
##---- Render country selection by server (conditional on source)
output$country_input <- renderUI({
selectInput("country_output", "Choose a country or region:",
selected = "Switzerland",
get_countries(d()))
# output$country_input <- renderUI({
# selectInput("country_output", "Choose a country or region:",
# # selected = "Switzerland",
# get_countries(d()))
# })
observeEvent(input$source, {
updateSelectInput(session, "country", "Choose a country or region:",
choices = get_countries(d()))
})
population <- reactive({
pop <- read_csv(file.path("data", tolower(input$source), paste0(input$source, "_population.csv")))
get_population(pop, input$country_output)
get_population(pop, input$country)
})
output$population <- renderText({
......@@ -305,7 +309,7 @@ options(DT.options = list(
output$plot_cases_cumulative <- renderPlotly({
ic <- input$country_output
ic <- input$country
past <- d() %>%
filter(country == ic)
......@@ -329,7 +333,7 @@ options(DT.options = list(
output$plot_cases_daily <- renderPlotly({
ic <- input$country_output
ic <- input$country
past <- d() %>%
filter(country == ic)
past_obs <- past %>%
......@@ -454,7 +458,7 @@ options(DT.options = list(
})
output$plot_deaths_cumulative <- renderPlotly({
ic <- input$country_output
ic <- input$country
past <- d_deaths() %>%
filter(country == ic)
......@@ -478,7 +482,7 @@ options(DT.options = list(
})
output$plot_deaths_daily <- renderPlotly({
ic <- input$country_output
ic <- input$country
past <- d_deaths() %>%
filter(country == ic)
past_obs <- past %>%
......@@ -490,7 +494,7 @@ options(DT.options = list(
type = "bar",
color = as.factor(past$observed)
) %>% layout(
title = paste("Daily number of deaths for", input$country_output, "on", refday),
title = paste("Daily number of deaths for", input$country, "on", refday),
annotations = b,
modebar = list(orientation = "v"),
margin = list(r = 150)) %>%
......@@ -505,7 +509,7 @@ options(DT.options = list(
output$growth_rate <- renderText({
ic <- input$country_output
ic <- input$country
rate <- d_growth() %>%
filter(Country == ic) %>%
......@@ -518,7 +522,7 @@ options(DT.options = list(
})
output$growth_rate_deaths <- renderText({
ic <- input$country_output
ic <- input$country
rate <- d_growth_death() %>%
filter(Country == ic) %>%
......@@ -531,7 +535,7 @@ options(DT.options = list(
})
preds <- reactive({
ic <- input$country_output
ic <- input$country
d() %>%
filter(country == ic) %>%
......@@ -549,7 +553,7 @@ options(DT.options = list(
})
preds_deaths <- reactive({
ic <- input$country_output
ic <- input$country
d_deaths() %>%
filter(country == ic) %>%
......@@ -567,7 +571,7 @@ options(DT.options = list(
})
cfr <- reactive({
ic <- input$country_output
ic <- input$country
cumul_cases <- d() %>%
filter(country == ic) %>%
......@@ -628,7 +632,7 @@ options(DT.options = list(
R_eff_output <- reactive({
ic <- input$country_output
ic <- input$country
past <- d() %>%
filter(country == ic)
past_obs <- past %>%
......@@ -702,5 +706,98 @@ options(DT.options = list(
lengthMenu = c(15, 30, 45, 60)))
)
# Exclude the inputs we don't need...
# setBookmarkExclude(c("table_rows_current",
# "table_cfr_state",
# "table_cell_clicked",
# "table_deaths_state",
# "table_deaths_search",
# "table_cfr_search",
# "sidebarItemExpanded",
# "table_deaths_rows_current",
# "r_eff_cases_rows_current",
# "table_deaths_row_last_clicked",
# "table_cfr_cell_clicked",
# "r_eff_cases_state",
# "table_state",
# "r_eff_cases_cell_clicked",
# "table_cfr_rows_current",
# "r_eff_cases_search",
# "table_deaths_cell_clicked",
# "table_rows_all",
# "table_cfr_rows_all",
# "sidebarCollapsed",
# "table_deaths_rows_all",
# "r_eff_cases_rows_selected",
# "r_eff_cases_rows_all",
# "table_cfr_row_last_clicked",
# "table_search",
# "plotly_relayout-A",
# "plotly_hover-A",
# "table_rows_selected",
# "table_cfr_rows_selected",
# "table_deaths_rows_selected",
# ".clientValue-default-plotlyCrosstalkOpts",
# "plotly_afterplot-A",
# "world_tests_cell_clicked",
# "world_tests_rows_current",
# "world_tests_rows_all",
# "world_tests_state",
# "world_tests_search",
# "world_tests_rows_selected"))
#
# observe({
# # Trigger this observer every time an input changes
# reactiveValuesToList(input)
# session$doBookmark()
# })
#
# onBookmarked(function(url) {
# updateQueryString(url)
# })
observe({
query <- parseQueryString(session$clientData$url_search)
if (!is.null(query[["tab"]])) {
updateTabItems(session, "tabs", selected = query[["tab"]])
}
if (!is.null(query[["source"]])) {
updateSelectInput(session, "source", selected = query[["source"]])
}
if (!is.null(query[["country"]])) {
updateSelectInput(session, "country", selected = query[["country"]])
}
# if (!is.null(query[["tab"]])) {
# if (query[["tab"]] == "predictions") {
# updateTabItems(session, "tabs", selected = query[["predictions"]])
# updateSelectInput(session, "source", selected = query[["?source"]])
# updateSelectInput(session, "country", selected = query[["?country"]])
# }
# }
# if (!is.null(query[["map"]])) {
# updateTabItems(session, "tabs", query[["map"]])
# }
})
# observeEvent(input$tabs, {
# updateQueryString(paste0("?tabs=", input$tabs)) #?tab=us_map
# })
# observeEvent(c(input$tabs, input$source, input$country), {
# updateQueryString(paste0("?tabs=", input$tabs))
# if (input$tabs == "predictions")
# updateQueryString(paste0(
# "?tabs=", input$tabs,
# "&?source=", input$source))
# # "&?country=", input$country))
# })
}
\ No newline at end of file
......@@ -13,7 +13,8 @@ library(metathis)
##----- Create the dashboard UI
ui <- dashboardPage(
ui <- function(requirements) {
dashboardPage(
dashboardHeader(title = "COVID-19 Forecasting"),
## Sidebar content
dashboardSidebar(
......@@ -69,14 +70,19 @@ ui <- dashboardPage(
selectInput(
"source",
"Choose a data source:",
selected = "ECDC",
# selected = "ECDC",
c("ECDC", "JHU", "JHU_US")
)
),
box(
width = 3,
title = "Country or region selection",
uiOutput("country_input")
# uiOutput("country_input")
selectInput(
"country",
"Choose a country or region:",
choices = NULL
)
),
box(
width = 3,
......@@ -195,3 +201,4 @@ ui <- dashboardPage(
),
)
)
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment