# Launch the ShinyApp (Do not remove this comment)
# To deploy, run: rsconnect::deployApp()
# Or use the blue button on top of this file
library(data.table)
library(here)
library(shinyjs)
library(crowdforecastr)
# load submission date from data if on server
if (!dir.exists("crowd-forecast")) {
submission_date <- readRDS(here("data-raw", "submission_date.rds"))
} else {
# just for local testing, set arbitrary submission date
submission_date <- Sys.Date() + 7
}
# set first forecast date to the Saturday after that
first_forecast_date <- submission_date + 5
# load observations
deaths_inc <- fread(here("data-raw", "weekly-incident-deaths.csv"))[
, target_type := "deaths"]
cases_inc <- fread(here("data-raw", "weekly-incident-cases.csv"))[
, target_type := "cases"]
# bind together and sort according to date and location
observations <- rbindlist(list(deaths_inc, cases_inc))
locs <- observations$location_name %>% unique
observations[
, location_name := factor(location_name,
levels = c("United Kingdom",
locs[locs != "United Kingdom"]))
]
setorder(observations, target_type, target_end_date, location_name)
observations[, location_name := as.character(location_name)]
# run app
run_app(data = observations,
first_forecast_date = as.character(first_forecast_date),
selection_vars = c("location_name", "target_type"),
path_service_account_json = ".secrets/crowd-forecast-app-c98ca2164f6c-service-account-token.json",
google_account_mail = "epiforecasts@gmail.com",
forecast_sheet_id = "1nOy3BfHoIKCHD4dfOtJaz4QMxbuhmEvsWzsrSMx_grI",
user_data_sheet_id = "1GJ5BNcN1UfAlZSkYwgr1-AxgsVA2wtwQ9bRwZ64ZXRQ",
submission_date = as.character(submission_date))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.