Package overview

Installing and loading the package

The package can either be installed from CRAN, from our drat repository, or from GitHub. See the README for details. Once installed load the package using the following,

library(covidregionaldata)

Worldwide data

Accessing national data

Both the World Health Organisation (WHO) and European Centre for Disease Control (ECDC) provide worldwide national data. Access national level data for any country using:

get_national_data()

This returns daily new and cumulative (total) cases, and where available, deaths, hospitalisations, and tests. For a complete list of variables returned, see section 5, “Data glossary” below. See the documentation (?get_national_data) for details of optional arguments.

Data is returned with no gaps in the structure of the data by country over time, and NAs fill in where data are not available.

Sub-national time-series data

Accessing sub-national data

Access sub-national level data for a specific country over time using get_regional_data(). Use get_available_datasets() to explore the currently supported sub-national datasets and select the data set of interest using the country (selects the country of interest), and level (selects the spatial scale of the data) arguments of get_regional_data.

This function returns daily new and cumulative (total) cases, and where available, deaths, hospitalisations, and tests. For a complete list of variables returned, see section 5, “Data glossary” below. See the documentation (?get_regional_data) for details of optional arguments.

As for national level data any gaps in reported data are filled with NAs.

For example, data for Belgium Level 1 regions over time can be accessed using:

get_regional_data(countries = "Belgium")

This returns a dataset in this format:

date region iso_code cases_new cases_total deaths_new deaths_total recovered_new recovered_total hosp_new hosp_total tested_new tested_total
2020-05-24 Wallonia BE-WAL 24 18196 16 3251 NA NA 8 5126 NA NA
2020-05-25 Brussels BE-BRU 26 5838 2 1421 NA NA 6 2533 NA NA
2020-05-25 Flanders BE-VLG 183 32381 14 4681 NA NA 29 9334 NA NA

Alternatively, the same data can be accessed using the underlying class as follows (the belgium object now contains data at each processing step and the methods used at each step),

belgium <- Belgium$new(get = TRUE)
belgium$return()

Level 1 and Level 2 regions

All countries included in the package (see below,“Coverage”) have data for regions at the admin-1 level, the largest administrative unit of the country (e.g. state in the USA). Some countries also have data for smaller areas at the admin-2 level (e.g. county in the USA).

Data for Level 2 units can be returned by using the level = "2" argument. The dataset will still show the corresponding Level 1 region.

An example of a country with Level 2 units is Belgium, where Level 2 units are Belgian provinces:

get_regional_data("Belgium", level = "2")

This returns a dataset with the format:

date province level_2_region_code region iso_code cases_new cases_total deaths_new deaths_total recovered_new recovered_total hosp_new hosp_total tested_new tested_total
2020-05-24 Brussels BE-BRU Brussels BE-BRU 7 5812 NA NA NA NA 4 2527 NA NA
2020-05-24 Antwerpen BE-VAN Flanders BE-VLG 16 7905 NA NA NA NA 5 2510 NA NA
2020-05-24 Limburg BE-VLI Flanders BE-VLG 14 6126 NA NA NA NA 2 1848 NA NA

Totals

For totalled data up to the most recent date available, use the totals argument.

get_regional_data("Belgium", totals = TRUE)

This returns a dataset with one row for each region, in the same format:

region iso_code cases_total deaths_total recovered_total hosp_total tested_total
Flanders BE-VLG 34195 4878 0 9694 0
Wallonia BE-WAL 19093 3362 0 5321 0
Brussels BE-BRU 6229 1482 0 2657 0

Data glossary

Subnational data

The data columns that will be returned by get_regional_data() are listed below.

To standardise across countries and regions, the columns returned for each country will always be the same. If the corresponding data was missing from the original source then that data field is filled with NA values (or 0 if accessing totals data).

Note that Date is not included if the totals argument is set to TRUE. Level 2 region/level 2 region code are not included if the level = "1".

National data

In addition to the above, the following columns are included when using get_national_data().