RtD3 has a number of features that are not required, but can improve the output of a visualization.
These features include:
To get started using RtD3 please see the documentation in “Creating an RtD3 visualization.”
Ensure that countries (or regions) have identical names in the goedata and summary data so that they will appear in the map and time series plots. We will prepare the geoData by resolving a name conflict between the geoData and estimates for the USA.
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"))
The data and config are then passed to RtD3::summaryWidget
.
RtD3::summaryWidget(
geoData = geoData,
rtData = rtData
)