Title: | Client for Delphi's 'Epidata' API |
---|---|
Description: | The Delphi 'Epidata' API provides real-time access to epidemiological surveillance data for influenza, 'COVID-19', and other diseases for the USA at various geographical resolutions, both from official government sources such as the Center for Disease Control (CDC) and Google Trends and private partners such as Facebook and Change 'Healthcare'. It is built and maintained by the Carnegie Mellon University Delphi research group. To cite this API: David C. Farrow, Logan C. Brooks, Aaron 'Rumack', Ryan J. 'Tibshirani', 'Roni' 'Rosenfeld' (2015). Delphi 'Epidata' API. <https://github.com/cmu-delphi/delphi-epidata>. |
Authors: | Logan Brooks [aut], Dmitry Shemetov [aut], Samuel Gratzl [aut], David Weber [ctb, cre], Nat DeFries [ctb], Alex Reinhart [ctb], Daniel J. McDonald [ctb], Kean Ming Tan [ctb], Will Townes [ctb], George Haff [ctb], Kathryn Mazaitis [ctb] |
Maintainer: | David Weber <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.2.0 |
Built: | 2024-11-14 23:24:29 UTC |
Source: | https://github.com/cmu-delphi/epidatr |
Fetches a data frame of all Epidata API endpoints that can be accessed using this package, with a brief description.
avail_endpoints()
avail_endpoints()
A tibble::tibble
of endpoints, with two columns:
Endpoint |
Name of the function for accessing this API endpoint. |
Description |
One-sentence description of the data available at the endpoint. |
avail_endpoints()
avail_endpoints()
Print out the information about the cache (as would be returned by cachem's
info()
method).
cache_info()
cache_info()
list
containing the info result as created by cachem
set_cache
to start a new cache (and general caching info),
clear_cache
to delete the cache and set a new one, and disable_cache
to
disable without deleting
Deletes the current cache and resets a new cache. Deletes local data! If you
are using a session unique cache, you will have to pass the arguments you
used for set_cache
earlier, otherwise the system-wide .Renviron
-based
defaults will be used.
clear_cache(..., disable = FALSE)
clear_cache(..., disable = FALSE)
... |
Arguments passed on to
|
disable |
instead of setting a new cache, disable caching entirely;
defaults to |
NULL
no return value, all effects are stored in the package
environment
set_cache
to start a new cache (and general caching info),
disable_cache
to only disable without deleting, and cache_info
Creates a helper object that can use auto-complete to help find COVIDcast
sources and signals. The COVIDcast endpoint of
the Epidata API contains many separate data sources and signals. It can be
difficult to find the name of the signal you're looking for, so you can use
covidcast_epidata
to get help with finding sources and functions without
leaving R.
The covidcast_epidata()
function fetches a list of all signals, and returns
an object containing fields for every signal:
epidata <- covidcast_epidata() epidata$signals #> # A tibble: 451 x 3 #> source signal short_description #> <chr> <chr> <chr> #> 1 chng smoothed_outpatient_cli Estimated percentage of outpatie~ #> 2 chng smoothed_adj_outpatient_cli Estimated percentage of outpatie~ #> 3 chng smoothed_outpatient_covid COVID-Confirmed Doctor Visits #> 4 chng smoothed_adj_outpatient_covid COVID-Confirmed Doctor Visits #> 5 chng smoothed_outpatient_flu Estimated percentage of outpatie~ #> 6 chng smoothed_adj_outpatient_flu Estimated percentage of outpatie~ #> 7 covid-act-now pcr_specimen_positivity_rate Proportion of PCR specimens test~ #> 8 covid-act-now pcr_specimen_total_tests Total number of PCR specimens te~ #> 9 doctor-visits smoothed_cli Percentage of daily doctor visit~ #> 10 doctor-visits smoothed_adj_cli Percentage of daily doctor visit~ #> # i 441 more rows
If you use an editor that supports tab completion, such as RStudio, type
epidata$signals$
and wait for the tab completion popup. You will be able
to type the name of signals and have the autocomplete feature select them
from the list for you. Note that some signal names have dashes in them, so
to access them we rely on the backtick operator:
epidata$signals$`fb-survey:smoothed_cli` #> [1] "COVID-Like Symptoms (Unweighted 7-day average)" #> [1] "fb-survey:smoothed_cli" #> [1] "Estimated percentage of people with COVID-like illness "
These objects can be used directly to fetch data, without requiring us to use
the pub_covidcast()
function. Simply use the $call
attribute of the object:
epidata$signals$`fb-survey:smoothed_cli`$call("state", "pa", epirange(20210405, 20210410)) #> # A tibble: 6 x 15 #> geo_value signal source geo_type time_type time_value direction issue #> <chr> <chr> <chr> <fct> <fct> <date> <dbl> <date> #> 1 pa smoothed_~ fb-su~ state day 2021-04-05 NA 2021-04-10 #> 2 pa smoothed_~ fb-su~ state day 2021-04-06 NA 2021-04-11 #> 3 pa smoothed_~ fb-su~ state day 2021-04-07 NA 2021-04-12 #> 4 pa smoothed_~ fb-su~ state day 2021-04-08 NA 2021-04-13 #> 5 pa smoothed_~ fb-su~ state day 2021-04-09 NA 2021-04-14 #> 6 pa smoothed_~ fb-su~ state day 2021-04-10 NA 2021-04-15 #> # i 7 more variables: lag <dbl>, missing_value <dbl>, missing_stderr <dbl>, #> # missing_sample_size <dbl>, value <dbl>, stderr <dbl>, sample_size <dbl>
covidcast_epidata(base_url = global_base_url, timeout_seconds = 30)
covidcast_epidata(base_url = global_base_url, timeout_seconds = 30)
base_url |
optional alternative API base url |
timeout_seconds |
the maximum amount of time to wait for a response |
An instance of covidcast_epidata
epidata_call
objects are generated internally by endpoint functions like
pub_covidcast
; by default, they are piped directly into the fetch
function to fetch and format the data. For most endpoints this will return
a tibble, but a few non-COVIDCAST endpoints will return a JSON-like list
instead.
create_epidata_call( endpoint, params, meta = NULL, only_supports_classic = FALSE ) fetch(epidata_call, fetch_args = fetch_args_list())
create_epidata_call( endpoint, params, meta = NULL, only_supports_classic = FALSE ) fetch(epidata_call, fetch_args = fetch_args_list())
endpoint |
the epidata endpoint to call |
params |
the parameters to pass to the epidata endpoint |
meta |
meta data to attach to the epidata call |
only_supports_classic |
if true only classic format is supported |
epidata_call |
an instance of |
fetch_args |
a |
create_epidata_call
is the constructor for epidata_call
objects, but you
should not need to use it directly; instead, use an endpoint function,
e.g., pub_covidcast
, to generate an epidata_call
for the data of
interest.
There are some other functions available for debugging and advanced usage: -
request_url
(for debugging): outputs the request URL from which data
would be fetched (note additional parameters below)
fetch
usually returns the data in tibble format, but a few of the
endpoints only support the JSON classic format (pub_delphi
,
pvt_meta_norostat
, and pub_meta
). In that case a
JSON-like nested list structure is returned instead.
For create_epidata_call
: an epidata_call
object
For fetch
: a tibble or a JSON-like list
## Not run: call <- pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", time_type = "day", geo_type = "state", time_values = epirange(20200601, 20200801), geo_values = c("ca", "fl"), fetch_args = fetch_args_list(dry_run = TRUE) ) call %>% fetch() ## End(Not run)
## Not run: call <- pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", time_type = "day", geo_type = "state", time_values = epirange(20200601, 20200801), geo_values = c("ca", "fl"), fetch_args = fetch_args_list(dry_run = TRUE) ) call %>% fetch() ## End(Not run)
Disable caching until you call set_cache
or restart R. The files defining
the cache are untouched. If you are looking to disable the caching more
permanently, set EPIDATR_USE_CACHE=FALSE
as environmental variable in
your .Renviron
.
disable_cache()
disable_cache()
NULL
no return value, all effects are stored in the package
environment
set_cache
to start a new cache (and general caching info),
clear_cache
to delete the cache and set a new one, and cache_info
Specify a date range (in days or epiweeks) for an API request.
epirange(from, to)
epirange(from, to)
from |
The first date to request. Can be specified as a |
to |
The final date to request (inclusive), specified the same way as
|
Epiweeks, also known as MMWR weeks number the weeks of the year from 1 to 53, each week spanning from Sunday to Saturday. The numbering is defined by the CDC.
An EpiRange
object.
# Represents 2021-01-01 to 2021-01-07, inclusive epirange(20210101, 20210107) # The same, but using Date objects epirange(as.Date("2021-01-01"), as.Date("2021-01-07")) # Represents epiweeks 2 through 4 of 2022, inclusive epirange(202202, 202204)
# Represents 2021-01-01 to 2021-01-07, inclusive epirange(20210101, 20210107) # The same, but using Date objects epirange(as.Date("2021-01-01"), as.Date("2021-01-07")) # Represents epiweeks 2 through 4 of 2022, inclusive epirange(202202, 202204)
Used to specify custom options when making API requests, such as to set
timeouts or change data formats. These options are used by fetch()
when it
makes calls to the Epidata API.
fetch_args_list( ..., fields = NULL, disable_date_parsing = FALSE, disable_data_frame_parsing = FALSE, return_empty = FALSE, timeout_seconds = 15 * 60, base_url = NULL, dry_run = FALSE, debug = FALSE, format_type = c("json", "classic", "csv") )
fetch_args_list( ..., fields = NULL, disable_date_parsing = FALSE, disable_data_frame_parsing = FALSE, return_empty = FALSE, timeout_seconds = 15 * 60, base_url = NULL, dry_run = FALSE, debug = FALSE, format_type = c("json", "classic", "csv") )
... |
not used for values, forces later arguments to bind by name |
fields |
a list of epidata fields to return, or |
disable_date_parsing |
disable automatic date parsing |
disable_data_frame_parsing |
disable automatic conversion to data frame; this is only supported by endpoints that only support the 'classic' format (non-tabular) |
return_empty |
boolean that allows returning an empty tibble if there is no data |
timeout_seconds |
the maximum amount of time (in seconds) to wait for a response from the API server |
base_url |
base URL to use; by default |
dry_run |
if |
debug |
if |
format_type |
the format to request from the API, one of classic, json,
csv; this is only used by |
A fetch_args
object containing all the specified options
Get and set the API key used to make requests to the Epidata API. Without a key, requests may be subject to rate limits and other limitations.
get_api_key() save_api_key()
get_api_key() save_api_key()
We recommend you register for an API key. While most endpoints are available without one, there are limits on API usage for anonymous users, including a rate limit. If you regularly request large amounts of data, please consider registering for an API key.
API keys are strings read from the environment variable DELPHI_EPIDATA_KEY
.
We recommend setting your key with save_api_key()
, which will modify an
applicable .Renviron
file, which will be read in automatically when you
start future R sessions (see ?Startup
for details on
.Renviron
files). Alternatively, you can modify the environment variable at
the command line before/while launching R, or inside an R session with
Sys.setenv()
, but these will not persist across sessions.
Once an API key is set, it is automatically used for all requests made by functions in this package.
For get_api_key()
, returns the current API key as a string, or
""
if none is set.
API docs: https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility.html
Obtains the COVID-19 reported patient impact and hospital capacity data by
facility. This dataset is provided by the US Department of Health & Human
Services. The companion function pub_covid_hosp_facility_lookup()
can be
used to look up facility identifiers in a variety of ways.
pub_covid_hosp_facility( hospital_pks, collection_weeks = "*", ..., publication_dates = NULL, fetch_args = fetch_args_list() )
pub_covid_hosp_facility( hospital_pks, collection_weeks = "*", ..., publication_dates = NULL, fetch_args = fetch_args_list() )
hospital_pks |
character. Facility identifiers. |
collection_weeks |
|
... |
not used for values, forces later arguments to bind by name |
publication_dates |
|
fetch_args |
|
Starting October 1, 2022, some facilities are only required to report annually.
pub_covid_hosp_facility()
, epirange()
## Not run: pub_covid_hosp_facility( hospital_pks = "100075", collection_weeks = epirange(20200101, 20200501) ) pub_covid_hosp_facility( hospital_pks = "050063", collection_weeks = epirange(20240101, 20240301) ) ## End(Not run)
## Not run: pub_covid_hosp_facility( hospital_pks = "100075", collection_weeks = epirange(20200101, 20200501) ) pub_covid_hosp_facility( hospital_pks = "050063", collection_weeks = epirange(20240101, 20240301) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility_lookup.html
Obtains unique identifiers and other metadata for COVID hospitalization
facilities of interest. This is a companion endpoint to the
pub_covid_hosp_facility()
endpoint.
pub_covid_hosp_facility_lookup( ..., state = NULL, ccn = NULL, city = NULL, zip = NULL, fips_code = NULL, fetch_args = fetch_args_list() )
pub_covid_hosp_facility_lookup( ..., state = NULL, ccn = NULL, city = NULL, zip = NULL, fips_code = NULL, fetch_args = fetch_args_list() )
... |
not used for values, forces later arguments to bind by name |
state |
string. A two-letter character state abbreviation. |
ccn |
string. A facility CMS certification number. |
city |
string. A city name. |
zip |
string. A 5-digit zip code. |
fips_code |
string. A 5-digit fips county code, zero-padded. |
fetch_args |
|
Only one location argument needs to be specified. Combinations of the arguments are not currently supported.
## Not run: pub_covid_hosp_facility_lookup(state = "fl") pub_covid_hosp_facility_lookup(city = "southlake") ## End(Not run)
## Not run: pub_covid_hosp_facility_lookup(state = "fl") pub_covid_hosp_facility_lookup(city = "southlake") ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp.html.
Obtains the COVID-19 reported patient impact and hospital capacity data by state. This dataset is provided by the US Department of Health & Human Services.
pub_covid_hosp_state_timeseries( states, dates = "*", ..., as_of = NULL, issues = NULL, fetch_args = fetch_args_list() )
pub_covid_hosp_state_timeseries( states, dates = "*", ..., as_of = NULL, issues = NULL, fetch_args = fetch_args_list() )
states |
character. Two letter state abbreviations. |
dates |
|
... |
not used for values, forces later arguments to bind by name |
as_of |
Date. Optionally, the as of date for the issues to fetch. If not
specified, the most recent data is returned. Mutually exclusive with
|
issues |
|
fetch_args |
|
Starting October 1, 2022, some facilities are only required to report annually.
## Not run: pub_covid_hosp_state_timeseries( states = "fl", dates = epirange(20200101, 20200501) ) ## End(Not run)
## Not run: pub_covid_hosp_state_timeseries( states = "fl", dates = epirange(20200101, 20200501) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html
The primary endpoint for fetching COVID-19 data, providing access to a wide variety of signals from a wide variety of sources. See the API documentation link above for more. Delphi's COVIDcast public dashboard is powered by this endpoint.
pub_covidcast( source, signals, geo_type, time_type, geo_values = "*", time_values = "*", ..., as_of = NULL, issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_covidcast( source, signals, geo_type, time_type, geo_values = "*", time_values = "*", ..., as_of = NULL, issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
source |
string. The data source to query (see: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html). |
signals |
string. The signals to query from a specific source (see: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html). |
geo_type |
string. The geographic resolution of the data (see: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html). |
time_type |
string. The temporal resolution of the data (either "day" or "week", depending on signal). |
geo_values |
character. The geographies to return. Defaults to all ("*") geographies within requested geographic resolution (see: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html.). |
time_values |
|
... |
not used for values, forces later arguments to bind by name |
as_of |
Date. Optionally, the as of date for the issues to fetch. If not
specified, the most recent data is returned. Mutually exclusive with
|
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
pub_covidcast_meta()
, covidcast_epidata()
, epirange()
## Not run: pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = c("ca", "fl"), time_values = epirange(20200601, 20200801) ) pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = "*", time_values = epirange(20200601, 20200801) ) ## End(Not run)
## Not run: pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = c("ca", "fl"), time_values = epirange(20200601, 20200801) ) pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = "*", time_values = epirange(20200601, 20200801) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_meta.html.
Fetch a summary of metadata for all sources and signals that are available in the API, along with basic summary statistics such as the dates they are available, the geographic levels at which they are reported, and etc.
pub_covidcast_meta(fetch_args = fetch_args_list())
pub_covidcast_meta(fetch_args = fetch_args_list())
fetch_args |
|
pub_covidcast()
,covidcast_epidata()
## Not run: pub_covidcast_meta() ## End(Not run)
## Not run: pub_covidcast_meta() ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/delphi.html
pub_delphi(system, epiweek, fetch_args = fetch_args_list())
pub_delphi(system, epiweek, fetch_args = fetch_args_list())
system |
character. System name to fetch. |
epiweek |
|
fetch_args |
|
## Not run: pub_delphi(system = "ec", epiweek = 201501) ## End(Not run)
## Not run: pub_delphi(system = "ec", epiweek = 201501) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/dengue_nowcast.html
pub_dengue_nowcast(locations, epiweeks = "*", fetch_args = fetch_args_list())
pub_dengue_nowcast(locations, epiweeks = "*", fetch_args = fetch_args_list())
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pub_dengue_nowcast( locations = "pr", epiweeks = epirange(201401, 202301) ) ## End(Not run)
## Not run: pub_dengue_nowcast( locations = "pr", epiweeks = epirange(201401, 202301) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/ecdc_ili.html.
Obtain information on influenza-like-illness from the European Centre for Disease Prevention and Control.
pub_ecdc_ili( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_ecdc_ili( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
regions |
character. Regions to fetch. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
The list of location argument can be found in https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/ecdc_regions.txt.
## Not run: pub_ecdc_ili(regions = "austria", epiweeks = epirange(201901, 202001)) ## End(Not run)
## Not run: pub_ecdc_ili(regions = "austria", epiweeks = epirange(201901, 202001)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/flusurv.html.
Obtain information on influenza hospitalization rates from the Center of Disease Control.
See also https://gis.cdc.gov/GRASP/Fluview/FluHospRates.html.
pub_flusurv( locations, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_flusurv( locations, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
locations |
character. Character vector indicating location. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
The list of location argument can be found in https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/flusurv_locations.txt.
## Not run: pub_flusurv(locations = "CA", epiweeks = epirange(201701, 201801)) ## End(Not run)
## Not run: pub_flusurv(locations = "CA", epiweeks = epirange(201701, 201801)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/fluview.html. For
Obtains information on outpatient inluenza-like-illness (ILI) from U.S. Outpatient Influenza-like Illness Surveillance Network (ILINet).
more information on ILINet, see https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html.
pub_fluview( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, auth = NULL, fetch_args = fetch_args_list() )
pub_fluview( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, auth = NULL, fetch_args = fetch_args_list() )
regions |
character. Locations to fetch. Can be any string IDs in national, HHS region, census division, most states and territories, and so on. Full list link below. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
auth |
string. Optionally, restricted access key (not the same as API key). |
fetch_args |
|
The full list of location inputs can be accessed at https://github.com/cmu-delphi/delphi-epidata/blob/main/src/acquisition/fluview/fluview_locations.py.
## Not run: pub_fluview(regions = "nat", epiweeks = epirange(201201, 202005)) ## End(Not run)
## Not run: pub_fluview(regions = "nat", epiweeks = epirange(201201, 202005)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/fluview_clinical.html
pub_fluview_clinical( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_fluview_clinical( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
regions |
character. Regions to fetch. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
## Not run: pub_fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701)) ## End(Not run)
## Not run: pub_fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/fluview_meta.html
pub_fluview_meta(fetch_args = fetch_args_list())
pub_fluview_meta(fetch_args = fetch_args_list())
fetch_args |
|
## Not run: pub_fluview_meta() ## End(Not run)
## Not run: pub_fluview_meta() ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/gft.html
Obtains estimates of inluenza activity based on volume of certain search queries from Google.
pub_gft(locations, epiweeks = "*", fetch_args = fetch_args_list())
pub_gft(locations, epiweeks = "*", fetch_args = fetch_args_list())
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
Google has discontinued Flu Trends and this is now a static endpoint. Possibile input for locations can be found in https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/regions.txt, https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/states.txt, and https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/cities.txt.
## Not run: pub_gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) ## End(Not run)
## Not run: pub_gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/kcdc_ili.html
pub_kcdc_ili( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_kcdc_ili( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
regions |
character. Regions to fetch. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
## Not run: pub_kcdc_ili(regions = "ROK", epiweeks = 200436) ## End(Not run)
## Not run: pub_kcdc_ili(regions = "ROK", epiweeks = 200436) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/meta.html
pub_meta(fetch_args = fetch_args_list())
pub_meta(fetch_args = fetch_args_list())
fetch_args |
|
API docs: https://cmu-delphi.github.io/delphi-epidata/api/nidss_dengue.html
Obtains counts of confirmed dengue cases in Taiwan from Taiwan National Infectious Disease Statistical System.
pub_nidss_dengue(locations, epiweeks = "*", fetch_args = fetch_args_list())
pub_nidss_dengue(locations, epiweeks = "*", fetch_args = fetch_args_list())
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
Possible location inputs can be found in https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/nidss_regions.txt and https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/nidss_locations.txt.
## Not run: pub_nidss_dengue(locations = "taipei", epiweeks = epirange(201201, 201301)) ## End(Not run)
## Not run: pub_nidss_dengue(locations = "taipei", epiweeks = epirange(201201, 201301)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/nidss_flu.html
Obtains information on outpatient inluenza-like-illness from Taiwan National Infectious Disease Statistical System.
pub_nidss_flu( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_nidss_flu( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
regions |
character. Regions to fetch. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
## Not run: pub_nidss_flu(regions = "taipei", epiweeks = epirange(201501, 201601)) ## End(Not run)
## Not run: pub_nidss_flu(regions = "taipei", epiweeks = epirange(201501, 201601)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/nowcast.html.
Obtains information on outpatient inluenza-like-illness (ILI) from Delphi's
pub_nowcast(locations, epiweeks = "*", fetch_args = fetch_args_list())
pub_nowcast(locations, epiweeks = "*", fetch_args = fetch_args_list())
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
The full list of location inputs can be accessed at https://github.com/cmu-delphi/delphi-epidata/blob/main/src/acquisition/fluview/fluview_locations.py.
## Not run: pub_nowcast(locations = "ca", epiweeks = epirange(201201, 201301)) ## End(Not run)
## Not run: pub_nowcast(locations = "ca", epiweeks = epirange(201201, 201301)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/paho_dengue.html
pub_paho_dengue( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
pub_paho_dengue( regions, epiweeks = "*", ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list() )
regions |
character. Regions to fetch. |
epiweeks |
|
... |
not used for values, forces later arguments to bind by name |
issues |
|
lag |
integer. Optionally, the lag of the issues to fetch. If not set,
the most recent issue is returned. Mutually exclusive with |
fetch_args |
|
## Not run: pub_paho_dengue(regions = "ca", epiweeks = epirange(201401, 201501)) ## End(Not run)
## Not run: pub_paho_dengue(regions = "ca", epiweeks = epirange(201401, 201501)) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/wiki.html Number of page visits for selected English, Influenza-related wikipedia articles.
Source: Wikimedia
Temporal Resolution: Hourly, daily, and weekly from 2007-12-09 (2007w50)
Spatial Resolution: N/A
Other resolution: By article (54)
Open access
pub_wiki( articles, ..., time_type = c("day", "week"), time_values = "*", hours = NULL, language = "en", fetch_args = fetch_args_list() )
pub_wiki( articles, ..., time_type = c("day", "week"), time_values = "*", hours = NULL, language = "en", fetch_args = fetch_args_list() )
articles |
character. Articles to fetch. |
... |
not used for values, forces later arguments to bind by name |
time_type |
string. The temporal resolution of the data (either "day" or "week", depending on signal). |
time_values |
|
hours |
integer. Optionally, the hours to fetch. |
language |
string. Language to fetch. |
fetch_args |
|
## Not run: pub_wiki( articles = "avian_influenza", time_type = "week", time_values = epirange(201501, 201601) ) ## End(Not run)
## Not run: pub_wiki( articles = "avian_influenza", time_type = "week", time_values = epirange(201501, 201601) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/cdc.html
pvt_cdc(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
pvt_cdc(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
auth |
string. Restricted access key (not the same as API key). |
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pvt_cdc( auth = Sys.getenv("SECRET_API_AUTH_CDC"), locations = "fl,ca", epirange(201501, 201601) ) ## End(Not run)
## Not run: pvt_cdc( auth = Sys.getenv("SECRET_API_AUTH_CDC"), locations = "fl,ca", epirange(201501, 201601) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/dengue_sensors.html
pvt_dengue_sensors( auth, names, locations, epiweeks = "*", fetch_args = fetch_args_list() )
pvt_dengue_sensors( auth, names, locations, epiweeks = "*", fetch_args = fetch_args_list() )
auth |
string. Restricted access key (not the same as API key). |
names |
character. Names to fetch. |
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pvt_dengue_sensors( auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "ght", locations = "ag", epiweeks = epirange(201501, 202001) ) ## End(Not run)
## Not run: pvt_dengue_sensors( auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "ght", locations = "ag", epiweeks = epirange(201501, 202001) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/ght.html
Estimate of influenza activity based on volume of certain search queries. …
pvt_ght(auth, locations, epiweeks = "*", query, fetch_args = fetch_args_list())
pvt_ght(auth, locations, epiweeks = "*", query, fetch_args = fetch_args_list())
auth |
string. Restricted access key (not the same as API key). |
locations |
character. Locations to fetch. |
epiweeks |
|
query |
string. The query to be fetched. |
fetch_args |
|
## Not run: pvt_ght( auth = Sys.getenv("SECRET_API_AUTH_GHT"), locations = "ma", epiweeks = epirange(199301, 202304), query = "how to get over the flu" ) ## End(Not run)
## Not run: pvt_ght( auth = Sys.getenv("SECRET_API_AUTH_GHT"), locations = "ma", epiweeks = epirange(199301, 202304), query = "how to get over the flu" ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/meta_norostat.html
pvt_meta_norostat(auth, fetch_args = fetch_args_list())
pvt_meta_norostat(auth, fetch_args = fetch_args_list())
auth |
string. Restricted access key (not the same as API key). |
fetch_args |
|
## Not run: pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) ## End(Not run)
## Not run: pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) ## End(Not run)
This is point data only, and does not include minima or maxima.
API docs: https://cmu-delphi.github.io/delphi-epidata/api/norostat.html
This is the documentation of the API for accessing the NoroSTAT endpoint of the Delphi’s epidemiological data.
pvt_norostat(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
pvt_norostat(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
auth |
string. Your authentication key. |
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pvt_norostat( auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin", epiweeks = 201233 ) ## End(Not run)
## Not run: pvt_norostat( auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin", epiweeks = 201233 ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/quidel.html
Data provided by Quidel Corp., which contains flu lab test results.
pvt_quidel(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
pvt_quidel(auth, locations, epiweeks = "*", fetch_args = fetch_args_list())
auth |
string. Restricted access key (not the same as API key). |
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pvt_quidel( auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), epiweeks = epirange(201201, 202001), locations = "hhs1" ) ## End(Not run)
## Not run: pvt_quidel( auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), epiweeks = epirange(201201, 202001), locations = "hhs1" ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/sensors.html
This is the documentation of the API for accessing the Digital Surveillance Sensors endpoint of the Delphi’s epidemiological. Note: this repository was built to support modeling and forecasting efforts surrounding seasonal influenza (and dengue). In the current COVID-19 pandemic, syndromic surveillance data, like ILI data (influenza-like illness) through FluView, will likely prove very useful. However, we urge caution to users examining the digital surveillance sensors, like ILI Nearby, Google Flu Trends, etc., during the COVID-19 pandemic, because these were designed to track ILI as driven by seasonal influenza, and were NOT designed to track ILI during the COVID-19 pandemic.
pvt_sensors( auth, names, locations, epiweeks = "*", fetch_args = fetch_args_list() )
pvt_sensors( auth, names, locations, epiweeks = "*", fetch_args = fetch_args_list() )
auth |
string. Restricted access key (not the same as API key). |
names |
character. Sensor names to fetch. |
locations |
character. Locations to fetch. |
epiweeks |
|
fetch_args |
|
## Not run: pvt_sensors( auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(201501, 202001) ) ## End(Not run)
## Not run: pvt_sensors( auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(201501, 202001) ) ## End(Not run)
API docs: https://cmu-delphi.github.io/delphi-epidata/api/twitter.html
This is the API documentation for accessing the Twitter Stream endpoint of Delphi’s epidemiological data. Sourced from Healthtweets
pvt_twitter( auth, locations, ..., time_type = c("day", "week"), time_values = "*", fetch_args = fetch_args_list() )
pvt_twitter( auth, locations, ..., time_type = c("day", "week"), time_values = "*", fetch_args = fetch_args_list() )
auth |
string. Restricted access key (not the same as API key). |
locations |
character. Locations to fetch. |
... |
not used for values, forces later arguments to bind by name |
time_type |
string. The temporal resolution of the data (either "day" or "week", depending on signal). |
time_values |
|
fetch_args |
|
## Not run: pvt_twitter( auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "CA", time_type = "week", time_values = epirange(201501, 202001) ) ## End(Not run)
## Not run: pvt_twitter( auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "CA", time_type = "week", time_values = epirange(201501, 202001) ) ## End(Not run)
By default, epidatr re-requests data from the API on every call of fetch
.
In case you find yourself repeatedly calling the same data, you can enable
the cache using either this function for a given session, or environmental
variables for a persistent cache.
The typical recommended workflow for using the cache is to set the
environmental variables EPIDATR_USE_CACHE=TRUE
and
EPIDATR_CACHE_DIRECTORY="/your/directory/here"
in your .Renviron
, for
example by calling usethis::edit_r_environ()
.
See the parameters below for some more configurables if you're so inclined.
set_cache
(re)defines the cache to use in a particular R session. This does
not clear existing data at any previous location, but instead creates a
handle to the new cache using cachem
that seamlessly handles caching for you.
Say your cache is normally stored in some default directory, but for the
current session you want to save your results in
~/my/temporary/savedirectory
, then you would call set_cache(dir = "~/my/temporary/savedirectory")
.
Or if you know the data from 2 days ago is wrong, you could call
set_cache(days = 1)
to clear older data whenever the cache is referenced.
In both cases, these changes would only last for a single session (though the
deleted data would be gone permanently!).
An important feature of the caching in this package is that only calls which
specify either issues
before a certain date, or as_of
before a certain
date will actually cache. For example the call
pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = "ca,fl", time_values = epirange(20200601, 20230801) )
won't cache, since it is possible for the cache to be invalidated by new releases with no warning. On the other hand, the call
pub_covidcast( source = "jhu-csse", signals = "confirmed_7dav_incidence_prop", geo_type = "state", time_type = "day", geo_values = "ca,fl", time_values = epirange(20200601, 20230801), as_of = "2023-08-01" )
will cache, since normal new versions of data can't invalidate it (since
they would be as_of
a later date). It is still possible that Delphi may
patch such data, but the frequency is on the order of months rather than
days. We are working on creating a public channel to communicate such
updates. While specifying issues
will usually cache, a call with
issues="*"
won't cache, since its subject to cache invalidation by normal
versioning.
On the backend, the cache uses cachem, with filenames generated using an md5 encoding of the call url. Each file corresponds to a unique epidata-API call.
set_cache( cache_dir = NULL, days = NULL, max_size = NULL, logfile = NULL, confirm = TRUE, startup = FALSE )
set_cache( cache_dir = NULL, days = NULL, max_size = NULL, logfile = NULL, confirm = TRUE, startup = FALSE )
cache_dir |
the directory in which the cache is stored. By default, this
is |
days |
the maximum length of time in days to keep any particular cached
call. By default this is |
max_size |
the size of the entire cache, in MB, at which to start
pruning entries. By default this is |
logfile |
where cachem's log of transactions is stored, relative to the
cache directory. By default, it is |
confirm |
whether to confirm directory creation. default is |
startup |
indicates whether the function is being called on
startup. Affects suppressability of the messages. Default is |
NULL
no return value, all effects are stored in the package
environment
clear_cache
to delete the old cache while making a new one,
disable_cache
to disable without deleting, and cache_info
set_cache( cache_dir = tempdir(), days = 14, max_size = 512, logfile = "logs.txt" )
set_cache( cache_dir = tempdir(), days = 14, max_size = 512, logfile = "logs.txt" )
Many API calls accept timesets to specify the time ranges of data being
requested. Timesets can be specified with epirange()
, as Date
objects, or
with wildcards.
Timesets are not special R types; the term simply describes any value that is accepted by epidatr to specify the time value of an epidata query:
Dates: Date
instances.
Date strings or integers: Strings or integers in the format YYYYMMDD.
Epiweeks: Strings or integers in the format YYYYWW, where WW is the epiweek number.
EpiRanges: A range returned by epirange()
, or a list of multiple ranges.
Wildcard: The string "*"
, which requests all available time values.
Refer to the specific endpoint documentation for guidance on using dates vs
weeks. Most endpoints support only one or the other. Some (less commonly
used) endpoints may not accept the "*"
wildcard, but this can be simulated
with a large epirange()
.