covid19 {COVID19}R Documentation

COVID-19 Data Hub

Description

Download COVID-19 data from https://covid19datahub.io

Usage

covid19(
  country = NULL,
  level = 1,
  start = "2010-01-01",
  end = Sys.Date(),
  vintage = NULL,
  wb = NULL,
  gmr = NULL,
  amr = NULL,
  dir = tempdir(),
  verbose = TRUE,
  ...
)

Arguments

country

vector of country names or ISO codes (ISO 3166-1 Alpha-2 code, Alpha-3 code, or numeric code). By default, downloads data for all countries.

level

integer. Granularity level. 1: country-level data. 2: state-level data. 3: lower-level data.

start, end

the start and the end date of the period of interest. The data are subsetted to match this time range.

vintage

date. This parameter allows to retrieve the snapshot of the dataset that was available on the given date. This typically differs from subsetting the latest data, as most governments are updating the data retroactively. Available since 2020-04-14.

wb

character vector of World Bank indicator codes. See details.

gmr

link to the Google Mobility Report dataset, or TRUE. See details.

amr

link to the Apple Mobility Report dataset, or TRUE. See details.

dir

folder where the data files are to be downloaded.

verbose

logical. Print on progress? Default TRUE.

...

backward compatibility, not used.

Details

Country-level covariates by World Bank Open Data can be added via the argument wb. This is a character vector of indicator codes to download. The codes can be found by inspecting the corresponding URL. For example, the code of the indicator "Hospital beds (per 1,000 people)" available at https://data.worldbank.org/indicator/SH.MED.BEDS.ZS is SH.MED.BEDS.ZS. The indicators are typically available at a yearly frequency. This function returns the latest data available between the start and the end date.

Mobility data by Google Mobility Reports can be added via the argument gmr. This is the link to the Google "CSV by geographic area" ZIP folder. At the time of writing, the link is https://www.gstatic.com/covid19/mobility/Region_Mobility_Report_CSVs.zip. As the link has been stable since the beginning of the pandemic, the function accepts gmr=TRUE to automatically use this link.

As of April 14, 2022, Apple is no longer providing COVID-19 mobility trends reports. If you have downloaded the data file previously, you can still use it by setting amr="path/to/file.csv".

Refer to this webpage for the details on the data sources, and see the changelog for the latest news about the dataset.

Value

data.frame. See the dataset documentation

Note

We have invested a lot of time and effort in creating COVID-19 Data Hub, please:

Source

https://covid19datahub.io

References

Guidotti, E., Ardia, D., (2020), "COVID-19 Data Hub", Journal of Open Source Software 5(51):2376, doi:10.21105/joss.02376.

Guidotti, E., (2022), "A worldwide epidemiological database for COVID-19 at fine-grained spatial resolution", Sci Data 9(1):112, doi:10.1038/s41597-022-01245-1.

Examples

## Not run: 

# Worldwide data by country
x <- covid19()

# Worldwide data by state
x <- covid19(level = 2)

# Data for specific countries by county/province
x <- covid19(c("Italy", "US"), level = 3)

# Retrieve the data that were available on 15 May, 2020
x <- covid19(vintage = "2020-05-15")

# Download the files in the folder "data"
dir.create("data")
x <- covid19(dir = "data")

# World Bank data
wb <- c("gdp" = "NY.GDP.MKTP.CD", "hosp_beds" = "SH.MED.BEDS.ZS")
x  <- covid19(wb = wb)

# Google Mobility Reports
x <- covid19(gmr = TRUE)

# Apple Mobility Reports
x <- covid19(amr = "path/to/file.csv")


## End(Not run)


[Package COVID19 version 3.0.3 Index]