Coder Social home page Coder Social logo

covid19datahub / r Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 14.0 76 KB

R Interface to COVID-19 Data Hub

Home Page: https://cran.r-project.org/package=COVID19

License: MIT License

R 100.00%
covid-data covid19-data coronavirus covid-19 2019-ncov r

r's Introduction

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}
}

r's People

Contributors

ardiad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

r's Issues

Warning message for dplyr 1.0.0

After updating the dplyr package to version 1.0.0, I got the following warning message when running covid19("US", level = 2, verbose = FALSE).

Warning message:
The keep argument of group_map() is deprecated as of dplyr 1.0.0.
Please use the .keep argument instead.

The results turned to be no problem. However, would you please fix this when updating this package?

No data from the 10/28

I don't see any data from the 10/28? Maybe things are not updating correctly from my end, but I just want to make sure...

Data not up-to-date

Hi,

The level-3 covid data pulled today (7/9) using R is not updated. The latest date is showing 7/7.

Thanks.

Data not updated

Hi,

The level-3 COVID data pulled today (8/4) using R is not updated. The data for 8/3 and 8/2 are the same.

Thanks.

Required R Version

In the package documentation it is mentioned that R versions 2.10 or higher would work. I am trying to install on R 3.4.3 and getting message that required version should be 3.5.0. Am I missing something?

Incomplete data: getting 35 countries with bare `covid19()`

Please advise how to get a more comprehensive record than the following:
image

Simple code for replication:

library(COVID19)
x <- covid19()
unique(x$administrative_area_level_1)

The dataframe x has 7750 observations, with 35 unique countries.

Data not current

Hi,

the data pulled today (26 June) does not seem to be current:

    library("COVID19")
    x <- covid19(level = 1)
    max(x$date)
    ## [1] "2020-06-24"

What am I doing wrong? Many thanks for looking into this.

Data has not been updated

Hi,

The level-3 COVID data pulled today (9/1) using R is not updated. The data for 8/31 and 8/30 are the same.

Thanks.

Missing countries, e.g. China, Hong Kong

Hi,
This is a very promising package. However, x <- covid19() returns no data for China, or Hong Kong...is this intentional (there may be other missing countries, but I haven't checked)?

No Data for 10/28

I don't see any data for 10/28? Maybe things are not updating correctly from my end, but I just want to make sure...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.