Skip to contents

This function initialises classes based on the DataClass() which allows documented downloading, cleaning, and processing. See the examples for some potential use cases and the DataClass() documentation for more details.

Usage

initialise_dataclass(
  class = character(),
  level = "1",
  totals = FALSE,
  localise = TRUE,
  regions,
  verbose = TRUE,
  steps = FALSE,
  get = FALSE,
  type = c("national", "regional"),
  ...
)

Arguments

class

A character string specifying the DataClass() to initialise. Not case dependent and matching is based on either the class name or the its country definition. 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.

regions

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

verbose

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

steps

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

get

Logical, defaults to FALSE. Should the class get method be called (this will download, clean, and process data at initialisation).

type

A character vector indicating the types of data to return. Current options include "national" (which are datasets at the national level which inherit from CountryDataClass) and "regional" (which are datasets at the regional level which inherit directly from DataClass()).

...

Additional arguments to pass to class specific functionality.

Value

An initialised version of the target class if available, e.g. Italy()

Examples

if (FALSE) {
# set up a cache to store data to avoid downloading repeatedly
start_using_memoise()

# check currently available datasets
get_available_datasets()

# initialise a data set in the United Kingdom
# at the UTLA level
utla <- UK$new(level = "2")

# download UTLA data
utla$download()

# clean UTLA data
utla$clean()

# inspect available level 1 regions
utla$available_regions(level = "1")

# filter data to the East of England
utla$filter("East of England")

# process UTLA data
utla$process()

# return processed and filtered data
utla$return()

# inspect all data steps
utla$data

# initialise Italian data, download, clean and process it
italy <- initialise_dataclass("Italy", get = TRUE)
italy$return()

# initialise ECDC data, fully process it, and return totals
ecdc <- initialise_dataclass("ecdc", get = TRUE, totals = TRUE)
ecdc$return()
}