This package provides an R client for the Delphi Epidata API.
library(epidatr)
epicall <- covidcast(
source = "fb-survey",
signals = "smoothed_cli",
geo_type = "nation",
time_type = "day",
geo_values = "us",
time_values = epirange(20210405, 20210410)
)
epicall %>% fetch()
# A tibble: 6 × 15
geo_value signal source geo_type time_type time_value
<chr> <chr> <chr> <fct> <fct> <date>
1 us smoothed_cli fb-surv… nation day 2021-04-05
2 us smoothed_cli fb-surv… nation day 2021-04-06
3 us smoothed_cli fb-surv… nation day 2021-04-07
4 us smoothed_cli fb-surv… nation day 2021-04-08
5 us smoothed_cli fb-surv… nation day 2021-04-09
6 us smoothed_cli fb-surv… nation day 2021-04-10
# ℹ 9 more variables: direction <dbl>, issue <date>,
# lag <int>, missing_value <int>, missing_stderr <int>,
# missing_sample_size <int>, value <dbl>, stderr <dbl>,
# sample_size <dbl>
Install from GitHub:
# Install the dev version using `pak` or `remotes`
pak::pkg_install("cmu-delphi/epidatr")
remotes::install_github("cmu-delphi/epidatr")
CRAN version coming soon.
The Delphi API requires a (free) API key for full functionality. To generate
your key, register for a pseudo-anonymous account
here and see more
discussion on the general API
website. The
epidatr
client will automatically look for this key in the R option
delphi.epidata.key
or in the environment variable
DELPHI_EPIDATA_KEY
. We recommend storing your key in .Renviron
file, which R
will read by default.
Note that for the time being, the private endpoints (i.e. those prefixed with
pvt
) will require a separate key that needs to be passed as an argument.