MyNixOS website logo
Description

R Interface to COVID-19 Data Hub.

Provides a daily summary of COVID-19 cases, deaths, recovered, tests, vaccinations, and hospitalizations for 230+ countries, 760+ regions, and 12000+ administrative divisions of lower level. Includes policy measures, mobility data, and geospatial identifiers. Data source: COVID-19 Data Hub <https://covid19datahub.io>.

R Interface to COVID-19 Data Hub

DOI

Provides a daily summary of COVID-19 cases, deaths, recovered, tests, vaccinations, and hospitalizations for 230+ countries, 760+ regions, and 12000+ administrative divisions of lower level. Includes policy measures, mobility data, and geospatial identifiers. Data source: COVID-19 Data Hub https://covid19datahub.io

Quickstart

# install the package
install.packages("COVID19")

# load the package
library("COVID19")

Usage

The only function in the package is covid19().

By default, the function downloads worldwide data by country:

x <- covid19()

Level

The argument level specifies the granularity of the data:

  • 1: country-level data
  • 2: state-level data
  • 3: lower-level data

Download worldwide data by state:

x <- covid19(level = 2)

Country

The argument country filters the data by country. This is a vector of country names or ISO codes (ISO 3166-1 Alpha-2 code, Alpha-3 code, or numeric code).

Download data for Italy and Unites States at county/province level:

x <- covid19(country = c("Italy", "US"), level = 3)

Time range

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

Download national-level data for United States from 01 October 2021 to 01 November 2021:

x <- covid19("US", start = "2021-10-01", end = "2021-11-01")

Vintage

The parameter vintage 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 14 April, 2020.

Retrieve the data that were available on 15 May, 2020:

x <- covid19(vintage = "2020-05-15")

Download folder

The argument dir specifies the folder where the data files are to be downloaded. By default this is a temporary folder.

Download the files in the folder data:

dir.create("data")
x <- covid19(dir = "data")

World Bank Open Data

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. Example using GDP and number of hospital beds:

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

Google Mobility Reports

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.

x <- covid19(gmr = TRUE)

Apple Mobility Reports

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".

x <- covid19(amr = "path/to/file.csv")

Documentation

See the full documentation online, or in R by typing ?covid19

Cite as

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

A BibTeX entry for LaTeX users is

@Article{,
    title = {COVID-19 Data Hub},
    year = {2020},
    doi = {10.21105/joss.02376},
    author = {Emanuele Guidotti and David Ardia},
    journal = {Journal of Open Source Software},
    volume = {5},
    number = {51},
    pages = {2376}
}
Metadata

Version

3.0.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows