Skip to contents

Provides an interface to source specific classes which support regional level data. For simple use cases this allows downloading clean, standardised, regional-level COVID-19 data sets. Internally this uses the DataClass() parent class which allows documented downloading, cleaning, and processing. Optionally all steps of data processing can be returned along with the functions used for processing but by default just the finalised processed data is returned. See the examples for some potential use cases and the links to lower level functions for more details and options.

Usage

get_regional_data(
  country,
  level = "1",
  totals = FALSE,
  localise = TRUE,
  steps = FALSE,
  class = FALSE,
  verbose = TRUE,
  regions,
  ...
)

Arguments

country

A character string specifying the country to get data from. Not case dependent. Name should be the English name. For a list of options use get_available_datasets().

level

A character string indicating the target administrative level of the data with the default being "1". Currently supported options are level 1 ("1) and level 2 ("2"). Use get_available_datasets() for supported options by dataset.

totals

Logical, defaults to FALSE. If TRUE, returns totalled data per region up to today's date. If FALSE, returns the full dataset stratified by date and region.

localise

Logical, defaults to TRUE. Should region names be localised.

steps

Logical, defaults to FALSE. Should all processing and cleaning steps be kept and output in a list.

class

Logical, defaults to FALSE. If TRUE returns the DataClass object rather than a tibble or a list of tibbles. Overrides steps.

verbose

Logical, defaults to TRUE. Should verbose processing messages and warnings be returned.

regions

A character vector of target regions to be assigned to the target_regions field and used to filter the returned data.

...

Additional arguments to pass to class specific functionality.

Value

A tibble with data related to cases, deaths, hospitalisations, recoveries and testing stratified by regions within the given country.

Examples

if (FALSE) {
# set up a data cache
start_using_memoise()

# download data for Italy
get_regional_data("italy")

# return totals for Italy with no localisation
get_regional_data("italy", localise = FALSE, totals = TRUE)

# download data for the UK but return the class
uk <- get_regional_data("United Kingdom", class = TRUE)
uk

# return UK data from the class object]
uk$return()
}