library(jsonlite) # import most recent epicurve reports and epicurve_ZKH of June 26 (last reported Reff_ZKH on June 12) filename_epicurve <- paste0("./___UITZONDERINGSGROND_6___epicurve_reports_", analysis_date, ".rds") if(file.exists(filename_epicurve)) { epicurve_Osiris <- readRDS(file = filename_epicurve) } else { stop(paste("Osiris epicurve file for", analysis_date, "not found. Run EstimationRt first")) } # not necessary since temporal split 2022-09-01 # epicurve_ZKH <- readRDS(file = paste0("./___UITZONDERINGSGROND_6___epicurve_", as.Date("2020-06-26"), ".rds")) # # # transition from ZKH to reports on June 12 # epicurve <- bind_rows("ziekenhuis" = epicurve_ZKH %>% rename(date = dates) %>% filter(date <= as.Date("2020-06-12")), # "meldingen" = epicurve_Osiris %>% filter(date > as.Date("2020-06-12")), # .id = "source") # json file for dashboard reproduction.json <- epicurve_Osiris %>% # select(date, caseRlower, caseR, caseRupper, source) %>% select(date, caseRlower, caseR, caseRupper) %>% # filter(date >= as.Date("2020-02-17")) %>% filter(date >= as.Date("2021-10-04")) %>% # temporal split: only report from 2021 W40 onwards mutate(caseR = ifelse(date > last(date) - 13, NA, caseR), caseR = ifelse(!is.na(caseR), format(round(caseR, digits = 2), nsmall = 2), NA), caseRlower = format(round(caseRlower, digits = 2), nsmall = 2), caseRupper = format(round(caseRupper, digits = 2), nsmall = 2), source = "testpos", # source = ifelse(source == "ziekenhuis", "hosp", "testpos"), # per 2022-02-08 berekening op testdatum ipv meldingsdatum -> version 2 # per 2022-09-02 temporal split -> version 4 version = 4) %>% rename(Date = date, Rt_low = caseRlower, Rt_avg = caseR, Rt_up = caseRupper, population = source) %>% toJSON write(x = reproduction.json, file = "./___UITZONDERINGSGROND_6___COVID-19_reproductiegetal.json") write(x = reproduction.json, file = paste0("./___UITZONDERINGSGROND_6___COVID-19_reproductiegetal_", analysis_date, ".json")) rm(filename_epicurve) rm(epicurve) rm(epicurve_ZKH) rm(reproduction.json)