Provides a flexible visualization of the country-level Covid-19 spread, inpired by the displays created by John Burn-Murdoch from the Financial Times. Uses data from the Johns Hopkins University CSSE team (https://github.com/CSSEGISandData/COVID-19), the ACAPS governmental measures database (https://www.acaps.org/covid19-government-measures-dataset), and the World Bank (https://data.worldbank.org). If your are overwhelmed with the options of the plot, explore them with shiny_covid19_spread() and use the 'copy code for plot to clipboard' option.

plot_covid19_spread(
  data = download_merged_data(cached = TRUE, silent = TRUE),
  type = "deaths",
  min_cases = ifelse(per_capita, ifelse(type == "deaths", 5, 50), ifelse(type ==
    "deaths", 1000, 10000)),
  min_by_ctry_obs = 7,
  edate_cutoff = 180,
  data_date_str = format(lubridate::as_date(data$timestamp[1]), "%B %d, %Y"),
  cumulative = TRUE,
  change_ave = 7,
  per_capita = FALSE,
  per_capita_x_axis = ifelse(per_capita, TRUE, FALSE),
  population_cutoff = 0,
  log_scale = TRUE,
  highlight = NULL,
  exclude_others = FALSE,
  intervention = NULL
)

Arguments

data

The data frame to base the plot on. Should be a merged data frame obtained by download_merged_data and defaults to download_merged_data(cached = TRUE, silent = TRUE).

type

The statistic that you want to plot. Needs to be either "confirmed", "deaths", "recovered" or "active", defined as the difference of "confirmed", "deaths" and "recovered".

min_cases

Defines the zero point of your X axis (the 'event date'). Defaults to 1,000 cases for deaths and 10,000 cases otherwise.

min_by_ctry_obs

Limits the plot to countries that have at least that many days of data since and including the event date. Defaults to 7.

edate_cutoff

The upper limit of the X axis in event days. Defaults to 180.

data_date_str

A date string to include in the annotation of the plot giving the time when the data was pulled. Defaults to the timestamp of the data. Note that you might run into issues with the default when running this in a non-english locale. Consider setting it by hand then.

cumulative

If TRUE (the default) data is being plotted as cumulative (showing the total figures). If FALSE, (averaged) daily changes are plotted instead. See change_ave to set the averaging window.

change_ave

Number of days to average over when you plot daily changes.

per_capita

If TRUE data is being plotted as per capita measure based on World Bank data. Defaults to FALSE.

per_capita_x_axis

If TRUE, the 'event date' cutoff for the x axis set by min_cases is evaluated based on by capita measures (cases per 100,000 inhabitants). Only feasible when per_capita is TRUE. Other than in older versions it now defaults to TRUE whenever per_capita is TRUE else FALSE.

population_cutoff

Do you want to restrict the plot to countries that exceed a certain population cutoff? Takes a value in millions and defaults to 0. Useful for per capita displays.

log_scale

Do you want the Y-axis to be log-scaled? Defaults to TRUE.

highlight

A character vector of ISO3c (ISO 3166-1 alpha-3) codes that identify countries that you want to highlight. Using the gghighlight package, these observations are highlighted by color and labeled while the other are grayed out. In NULL (the default), all countries are labeled. This can cause very cluttered plots.

exclude_others

If TRUE, unhighlighted countries are excluded from the plot. If FALSE (the default), unhighlighted countries are grayed out.

intervention

If not default NULL then this identifies the intervention type that you want to be highlighted by a point marker. Valid intervention types are based on the ACAPS government measure data and include general lockdowns ('lockdown'), social distancing ('soc_dist'), movement restrictions ('mov_rest'), public health measures ('pub_health'), and social and economic measures ('soc_econ').

Value

A ggplot2 object.

Examples

plot_covid19_spread()
#> Failed to get face: , 22041
merged <- download_merged_data(cached = TRUE, silent = TRUE) plot_covid19_spread(merged, highlight = "DEU", intervention = "lockdown")
plot_covid19_spread(merged, type = "recovered", min_by_ctry_obs = 10, edate_cutoff = 40, highlight = c("ITA", "ESP", "FRA", "DEU", "USA"), intervention = "soc_dist" )