detailed_config.Rmd
RtD3 has a number of features that are not required, but can improve the output of a visualization.
These features include:
We will prepare the geoData by resolving the USA name conflict between the geoData and estimates.
geoData <- rnaturalearth::ne_countries(returnclass = 'sf') geoData <- geoData %>% mutate(sovereignt = ifelse(sovereignt == 'United States of America', 'United States', sovereignt))
We will also add a second data source to the rtData. Here, rtData will have two items, “Cases” and “Deaths”. These labels are flexible and are passed to the dataset selector dropdown. Data can be extracted from EpiNow2
easily using the RtD3::readInEpinow2
function or as a list from other sources.
# Define the base URL/file path for the estimates base_url <- 'https://raw.githubusercontent.com/epiforecasts/covid-rt-estimates/master/national/' # Read in each summary folder rtData <- list("Cases" = RtD3::readInEpiNow2(path = paste0(base_url, "cases/summary"), region_var = "country"), "Deaths" = RtD3::readInEpiNow2(path = paste0(base_url, "deaths/summary"), region_var = "country")) # Extract summary data from cases summaryData <- rtData$Cases$summary ## Drop remaining summary data rtData <- lapply(rtData, function(.){.[-1]})
We can also configure a list of URLs to link more detailed estimates (using the RtD3::getSubregionalUrls
helper function).
subnational_ref <- RtD3::getSubregionalUrls(path = "https://epiforecasts.io/covid/posts/national/", areas = c('Afghanistan', 'Brazil', 'Colombia', 'India', 'Italy', 'Germany', 'Russia', 'United Kingdom', 'United States'))
The data and config are then passed to RtD3::summaryWidget
.
RtD3::summaryWidget( geoData = geoData, summaryData = summaryData, rtData = rtData, subregional_ref = subnational_ref )
## Warning in name_warning_geoData(name_diff): The following names are present
## in the estimates but not in the GeoData: Andorra, Antigua & Barbuda, Aruba,
## Bahamas, Bahrain ... and 31 more.
## Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.