From 2240c9f72bc56b2f68b911f1e9344bbbd9cd374e Mon Sep 17 00:00:00 2001 From: dsweber Date: Wed, 10 May 2023 22:00:17 -0500 Subject: [PATCH 01/13] first pass endpoints vignette (has active todos) namely, several endpoints are returning errors, and there are some with uncertain sourcing. documented inline with TODOs --- .gitignore | 1 + R/endpoints.R | 3 +- vignettes/covidcast.Rmd | 1 - vignettes/endpoints.Rmd | 387 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 390 insertions(+), 2 deletions(-) create mode 100644 vignettes/endpoints.Rmd diff --git a/.gitignore b/.gitignore index 8399e0fd..5325ba8a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ env .httr-oauth /doc/ /Meta/ +.secrets diff --git a/R/endpoints.R b/R/endpoints.R index 6fdb00ce..f0fd14d6 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -614,6 +614,7 @@ covidcast_meta <- function() { #' Fetch covidcast data #' #' API docs: +#' #' COVIDcast public dashboard: #' #' @examples @@ -630,7 +631,7 @@ covidcast_meta <- function() { #' @param data_source string. The data source to query (see: #' ). #' @param signals string. The signals to query from a specific source (see: -#' ). +#' ). #' @param geo_type string. The geographic resolution of the data (see: #' ). #' @param time_type string. The temporal resolution of the data (either "day" or diff --git a/vignettes/covidcast.Rmd b/vignettes/covidcast.Rmd index 9450d47e..e21d994f 100644 --- a/vignettes/covidcast.Rmd +++ b/vignettes/covidcast.Rmd @@ -21,7 +21,6 @@ library("epidatr") library("magrittr") ``` - ```{r} covidcast_api <- covidcast_epidata() epicall <- covidcast_api$sources$`fb-survey`$signals$smoothed_cli$call("nation", "us", epirange(20210405, 20210410)) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd new file mode 100644 index 00000000..995a2e8d --- /dev/null +++ b/vignettes/endpoints.Rmd @@ -0,0 +1,387 @@ +--- +title: "COVIDcast API Client" +author: "Delphi Group" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{COVIDcast API Client} + %\VignetteEngine{knitr::rmarkdown} + \usepackage[utf8]{inputenc} +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +```{r libraries} +# remotes::install_github("cmu-delphi/epidatr") +#library(devtools) +#load_all("epidatr") +library("epidatr") +library("magrittr") +library("dplyr") +``` + +The API endpoints, organized by data sources. + +## COVIDcast Main Endpoint + +All of these signals use the command `covidcast`, with variation in which source and signal are used. + +Data Sources and Signals documentation: + +Function reference: + +To understand the available sources better, use `covidcast_epidata()` and `covidcast_meta()`. +```{r} +covidcast_epidata() +``` +For example, let's see what kind of smoothed signals come out of the [facebook survey](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/fb-survey.html) source: +```{r} +cm <- covidcast_meta() %>% + fetch_tbl() %>% + dplyr::filter(grepl("smoothed", signal), data_source == "fb-survey") +``` +grabbing the first smoothed signal as an example: +```{r} +cm[1, ] %>% print(width = 100) +cm[1, "signal"] +``` +and actually fetching some data from this source +```{r} +covidcast( + data_source = "fb-survey", + signals = "smoothed_accept_covid_vaccine", + geo_type = "county", + time_type = "day", + time_values = epirange(20201221, 20201225), + geo_values = "06059" +) %>% fetch_tbl() +``` +County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed more here: . The example above is for Orange County, California. + +## Other Covid Endpoints + +### COVID-19 Hospitalization: Facility Lookup + +API docs: + +Function reference: + +Example calls: +```{r} +covid_hosp_facility_lookup(city = "southlake") %>% fetch_tbl() +``` + +```{r} +covid_hosp_facility_lookup(state = "WY") %>% fetch_tbl() +``` + +A non-example (there is no city called New York in Wyoming); + +```{r} +covid_hosp_facility_lookup(state = "WY", city = "New York") %>% fetch_tbl() +``` + +### COVID-19 Hospitalization by Facility + +API docs: + +Function reference: + +Example call: + +```{r} +covid_hosp_facility( + hospital_pks = "100075", + collection_weeks = epirange(20200101, 20200501) +) %>% fetch_tbl() +``` + +### COVID-19 Hospitalization by State + +API docs: + +Function reference: + +Example call: + +```{r} +covid_hosp_state_timeseries(states = "MA", dates = "20200510") %>% fetch_tbl() +``` + +## Flu Endpoints + +### Delphi's ILINet forecasts + +API docs: + +Function reference: + +Example call: + +```{r} +delphi(system = "ec", epiweek = 201501) %>% fetch_classic() +``` + + +### FluSurv hospitalization data + +API docs: + +Function reference: + +Example call: + +```{r} +flusurv(locations = "ca", epiweeks = 202001) %>% fetch_tbl() +``` + +### Fluview data + +API docs: + +Function reference: + +Example call: + +```{r} +fluview(regions = "nat", epiweeks = epirange(201201, 202001)) %>% fetch_tbl() +``` + +### Fluview virological data from clinical labs + +API docs: + +Function reference: + +Example call: + +```{r} +fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701)) %>% fetch_tbl() +``` +### Fluview metadata + +Function reference: + +Example call: + +```{r} +fluview_meta() %>% fetch_tbl() +``` + +TODO broken? + +### Google Flu Trends data +API docs: + +Function reference: + +```{r} +gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) %>% fetch_tbl() +``` + +### KCDC ILI +API docs: + +Function reference: + +kcdc_ili(regions = "01", epiweeks = epirange(199001, 202301)) %>% fetch_tbl() +TODO example is broken + +### NIDSS Flu +API docs: + +Function reference: + +```{r} +nidss_flu(regions = "taipei", epiweeks = epirange(200901, 201301)) %>% fetch_tbl() +``` + +### ILI Nearby Nowcast +API docs: + +Function reference: + +```{r} +nowcast(locations = "ca", epiweeks = epirange(202201, 202319)) %>% fetch_tbl() +``` + +## Dengue Endpoints + +### Delphi's Dengue Nowcast + +API docs: + +Function reference: + +Example call: + +```{r} +dengue_nowcast(locations = "pr", epiweeks = epirange(201401, 202301)) %>% fetch_tbl() +``` + +### NIDSS dengue +API docs: + +Function reference: + +```{r} +nidss_dengue(locations = "taipei", epiweeks = epirange(200301, 201301)) %>% fetch_tbl() +``` + +## PAHO Dengue + +API docs: + +Function reference: + +```{r} +paho_dengue(regions = "1", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() +``` +TODO this is disallowed (http 401) + +## Other Endpoints +### Wikipedia Access +API docs: + +Function reference: + +```{r} +wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319)) %>% fetch_tbl() +``` +# Private methods + +These require private access keys to use. To actually run these locally, if you have stored these secrets in `secrets.R`, first run +```{r} +source("secrets.R") +``` +Each source has it's own auth that it needs, which is the first argument. + +### AFHSB metadata + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_afhsb_meta(auth = SECRET_API_AUTH_AFHSB) %>% fetch_classic() +``` +TODO internal server error + +### AFHSB data + +API docs: + +Function reference: + +Example call: + +```{r, eval=false} +pvt_afhsb(auth = SECRET_API_AUTH_AFHSB, locations = "mn", epiweeks = epirange(202002, 202110), flu_types = "flu1") %>% fetch_tbl() +``` + +TODO 500 internal server error + +### CDC + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_cdc(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() +``` + +### Dengue Digital Surveillance Sensors + +API docs: + +Function reference: + +Example call: + +```{r, eval=false} +pvt_dengue_sensors(auth = SECRET_API_SENSORS, names = ) %>% fetch_tbl() +``` +TODO not in the reference docs either... + +### Google Health Trends + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() +``` + +### Google Health Trends + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() +``` + +### NoroSTAT metadata + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_meta_norostat(auth = SECRET_API_AUTH_NOROSTAT) %>% fetch_classic() +``` + +### NoroSTAT NoroSTAT data + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_norostat(auth = SECRET_API_AUTH_NOROSTAT, locations = "mn", epiweeks = epirange(201301, 202105)) %>% fetch_tbl() +``` +TODO can't seem to get a relevant sample, the example in the reference section is borked. + +### Quidel Covid and Influenza testing + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_quidel(auth = SECRET_API_AUTH_QUIDEL, locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() +``` + +### Sensors + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_sensors(auth = SECRET_API_AUTH_SENSORS, names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() +``` + +### Twitter + +API docs: + +Function reference: + +Example call: +```{r, eval=false} +pvt_twitter(auth = SECRET_API_AUTH_TWITTER, locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() +``` From 070ddf9de4b95361f3676d8b34993c449ee5069d Mon Sep 17 00:00:00 2001 From: dsweber Date: Wed, 10 May 2023 22:39:46 -0500 Subject: [PATCH 02/13] false->FALSE, don't call source on secrets --- vignettes/endpoints.Rmd | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index 995a2e8d..c6187153 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -236,7 +236,7 @@ API docs: Function reference: -```{r} +```{r, eval=FALSE} paho_dengue(regions = "1", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() ``` TODO this is disallowed (http 401) @@ -252,9 +252,9 @@ wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319 ``` # Private methods -These require private access keys to use. To actually run these locally, if you have stored these secrets in `secrets.R`, first run -```{r} -source("secrets.R") +These require private access keys to use. To actually run these locally, if you have stored these secrets in `secrets.R` in the root directory of this project, first run +```{r, eval=FALSE} +source("../secrets.R") ``` Each source has it's own auth that it needs, which is the first argument. @@ -265,7 +265,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_afhsb_meta(auth = SECRET_API_AUTH_AFHSB) %>% fetch_classic() ``` TODO internal server error @@ -278,7 +278,7 @@ Function reference: % fetch_tbl() ``` @@ -291,7 +291,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_cdc(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() ``` @@ -303,7 +303,7 @@ Function reference: % fetch_tbl() ``` TODO not in the reference docs either... @@ -315,7 +315,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() ``` @@ -326,7 +326,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() ``` @@ -337,7 +337,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_meta_norostat(auth = SECRET_API_AUTH_NOROSTAT) %>% fetch_classic() ``` @@ -348,7 +348,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_norostat(auth = SECRET_API_AUTH_NOROSTAT, locations = "mn", epiweeks = epirange(201301, 202105)) %>% fetch_tbl() ``` TODO can't seem to get a relevant sample, the example in the reference section is borked. @@ -360,7 +360,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_quidel(auth = SECRET_API_AUTH_QUIDEL, locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` @@ -371,7 +371,7 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_sensors(auth = SECRET_API_AUTH_SENSORS, names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` @@ -382,6 +382,6 @@ API docs: Function reference: Example call: -```{r, eval=false} +```{r, eval=FALSE} pvt_twitter(auth = SECRET_API_AUTH_TWITTER, locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` From 78b153204f98186c8ca8736e187ac4b1ca1be8a8 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 19 May 2023 13:31:23 -0700 Subject: [PATCH 03/13] ref docs: links, * ex, build I hadn't compiled the html link that was broken into the actual man pages. I added links to `covidcast_epidata` to `covidcast_meta` and `covidcast`, and an example of the use of * to covidcast. When I compiled the roxygen2 docs, an extra \details{ appeared, which I assume is because of a change someone else made that didn't get compiled in. --- R/endpoints.R | 12 ++++++++++-- man/covidcast.Rd | 14 ++++++++++++-- man/covidcast_meta.Rd | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index f0fd14d6..92e890d5 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -583,7 +583,7 @@ covid_hosp_state_timeseries <- function(states, dates, issues = NULL) { #' covidcast_meta() %>% fetch() #' } #' -#' @seealso [covidcast()] +#' @seealso [covidcast()],[covidcast_epidata()] #' @export covidcast_meta <- function() { create_epidata_call( @@ -627,6 +627,14 @@ covidcast_meta <- function() { #' geo_values = "ca,fl", #' time_values = epirange(20200601, 20200801) #' ) %>% fetch() +#' covidcast( +#' data_source = "jhu-csse", +#' signals = "confirmed_7dav_incidence_prop", +#' geo_type = "state", +#' time_type = "day", +#' geo_values = "*", +#' time_values = epirange(20200601, 20200801) +#' ) %>% fetch() #' } #' @param data_source string. The data source to query (see: #' ). @@ -651,7 +659,7 @@ covidcast_meta <- function() { #' `issues`. #' @return [`epidata_call`] #' -#' @seealso [covidcast_meta()], [epirange()] +#' @seealso [covidcast_meta()], [covidcast_epidata()], [epirange()] #' #' @export covidcast <- function( diff --git a/man/covidcast.Rd b/man/covidcast.Rd index 09280db5..566f2560 100644 --- a/man/covidcast.Rd +++ b/man/covidcast.Rd @@ -21,7 +21,7 @@ covidcast( \url{https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html}).} \item{signals}{string. The signals to query from a specific source (see: -\url{https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals}).} +\url{https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals.html}).} \item{geo_type}{string. The geographic resolution of the data (see: \url{https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html}).} @@ -52,6 +52,8 @@ the most recent issue is returned. Mutually exclusive with \code{as_of} or } \description{ API docs: \url{https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html} +} +\details{ COVIDcast public dashboard: \url{https://delphi.cmu.edu/covidcast/} } \examples{ @@ -64,8 +66,16 @@ covidcast( geo_values = "ca,fl", time_values = epirange(20200601, 20200801) ) \%>\% fetch() +covidcast( + data_source = "jhu-csse", + signals = "confirmed_7dav_incidence_prop", + geo_type = "state", + time_type = "day", + geo_values = "*", + time_values = epirange(20200601, 20200801) +) \%>\% fetch() } } \seealso{ -\code{\link[=covidcast_meta]{covidcast_meta()}}, \code{\link[=epirange]{epirange()}} +\code{\link[=covidcast_meta]{covidcast_meta()}}, \code{\link[=covidcast_epidata]{covidcast_epidata()}}, \code{\link[=epirange]{epirange()}} } diff --git a/man/covidcast_meta.Rd b/man/covidcast_meta.Rd index 3f9f8968..d134b674 100644 --- a/man/covidcast_meta.Rd +++ b/man/covidcast_meta.Rd @@ -25,5 +25,5 @@ covidcast_meta() \%>\% fetch() } \seealso{ -\code{\link[=covidcast]{covidcast()}} +\code{\link[=covidcast]{covidcast()}},\code{\link[=covidcast_epidata]{covidcast_epidata()}} } From fc7faa949ccbcfbbc9ff1fe229c54da904e73f95 Mon Sep 17 00:00:00 2001 From: dsweber Date: Sun, 14 May 2023 21:04:49 -0500 Subject: [PATCH 04/13] ex direct from database, title, * notes, Renviron the delphi endpoint's fetch_classic output has been modified to just names, since the full output is too long Secrets moved to the .Reviron file. Duplicate copy of Google Health Trends removed various references fixed --- vignettes/endpoints.Rmd | 81 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index c6187153..b7e89960 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -1,10 +1,10 @@ --- -title: "COVIDcast API Client" +title: "Endpoint Examples" author: "Delphi Group" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{COVIDcast API Client} + %\VignetteIndexEntry{Endpoint Examples} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} --- @@ -23,6 +23,7 @@ library("dplyr") ``` The API endpoints, organized by data sources. +Some endpoints allow for the use of `*` to access data at all locations. Check the help for a given endpoint to see if it supports `*`. ## COVIDcast Main Endpoint @@ -59,6 +60,17 @@ covidcast( ) %>% fetch_tbl() ``` County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed more here: . The example above is for Orange County, California. +Since `covidcast` is an endpoint which supports `*`, here is an example of its use: +```{r} +covidcast( + data_source = "fb-survey", + signals = "smoothed_accept_covid_vaccine", + geo_type = "county", + time_type = "day", + time_values = epirange(20201221, 20201225), + geo_values = "*" +) %>% fetch_tbl() +``` ## Other Covid Endpoints @@ -121,10 +133,10 @@ Function reference: Example call: ```{r} -delphi(system = "ec", epiweek = 201501) %>% fetch_classic() +del <- delphi(system = "ec", epiweek = 201501) %>% fetch_classic() +names(del$epidata$forecast) ``` - ### FluSurv hospitalization data API docs: @@ -170,8 +182,6 @@ Example call: fluview_meta() %>% fetch_tbl() ``` -TODO broken? - ### Google Flu Trends data API docs: @@ -186,9 +196,9 @@ API docs: Function reference: -kcdc_ili(regions = "01", epiweeks = epirange(199001, 202301)) %>% fetch_tbl() -TODO example is broken - +```{r} +kcdc_ili(regions = "ROK", epiweeks = 200436) %>% fetch_tbl() +``` ### NIDSS Flu API docs: @@ -237,9 +247,8 @@ API docs: Function reference: ```{r, eval=FALSE} -paho_dengue(regions = "1", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() +paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() ``` -TODO this is disallowed (http 401) ## Other Endpoints ### Wikipedia Access @@ -252,23 +261,20 @@ wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319 ``` # Private methods -These require private access keys to use. To actually run these locally, if you have stored these secrets in `secrets.R` in the root directory of this project, first run -```{r, eval=FALSE} -source("../secrets.R") -``` -Each source has it's own auth that it needs, which is the first argument. +These require private access keys to use. To actually run these locally, you will need to store these secrets in your `.Reviron` file, or set them as environmental variables. ### AFHSB metadata -API docs: +API docs: -Function reference: +Function reference: Example call: ```{r, eval=FALSE} -pvt_afhsb_meta(auth = SECRET_API_AUTH_AFHSB) %>% fetch_classic() +pvt_meta_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB")) %>% fetch_classic() ``` TODO internal server error +not on the server I was given access to ### AFHSB data @@ -279,10 +285,11 @@ Function reference: % fetch_tbl() +pvt_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB"), locations = "mn", epiweeks = epirange(202002, 202110), flu_types = "flu1") %>% fetch_tbl() ``` TODO 500 internal server error +not on the server I was given access to ### CDC @@ -292,7 +299,7 @@ Function reference: % fetch_tbl() +pvt_cdc(auth = Sys.getenv("SECRET_API_AUTH_CDC"), epiweeks = epirange(202003, 202304), locations = "ma") %>% fetch_tbl() ``` ### Dengue Digital Surveillance Sensors @@ -304,9 +311,8 @@ Function reference: % fetch_tbl() +pvt_dengue_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "ght", locations = "ag", epiweeks = epirange(201404, 202004)) %>% fetch_tbl() ``` -TODO not in the reference docs either... ### Google Health Trends @@ -316,18 +322,7 @@ Function reference: % fetch_tbl() -``` - -### Google Health Trends - -API docs: - -Function reference: - -Example call: -```{r, eval=FALSE} -pvt_ght(auth = SECRET_API_AUTH_CDC, epiweeks = epirange(202003, 20234), locations = "ma") %>% fetch_tbl() +pvt_ght(auth = Sys.getenv("SECRET_API_AUTH_GHT"), epiweeks = epirange(199301, 202304), locations = "ma", query = "how to get over the flu") %>% fetch_tbl() ``` ### NoroSTAT metadata @@ -338,10 +333,10 @@ Function reference: % fetch_classic() +pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) %>% fetch_classic() ``` -### NoroSTAT NoroSTAT data +### NoroSTAT data API docs: @@ -349,7 +344,7 @@ Function reference: % fetch_tbl() +pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "ma", epiweeks = epirange(199001, 202105)) %>% fetch_classic() ``` TODO can't seem to get a relevant sample, the example in the reference section is borked. @@ -361,7 +356,7 @@ Function reference: % fetch_tbl() +pvt_quidel(auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` ### Sensors @@ -372,16 +367,16 @@ Function reference: % fetch_tbl() +pvt_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` ### Twitter -API docs: +API docs: -Function reference: +Function reference: Example call: ```{r, eval=FALSE} -pvt_twitter(auth = SECRET_API_AUTH_TWITTER, locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() +pvt_twitter(auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` From b44ec9a27b84b974842bf9546e3138f09e53c55b Mon Sep 17 00:00:00 2001 From: dsweber Date: Mon, 15 May 2023 22:53:16 -0500 Subject: [PATCH 05/13] whitespace, dropping afhsb --- vignettes/endpoints.Rmd | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index b7e89960..f57cc3da 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -27,28 +27,35 @@ Some endpoints allow for the use of `*` to access data at all locations. Check t ## COVIDcast Main Endpoint -All of these signals use the command `covidcast`, with variation in which source and signal are used. +All of these signals use the command `covidcast`, with variation in which source and signal are used. Data Sources and Signals documentation: Function reference: -To understand the available sources better, use `covidcast_epidata()` and `covidcast_meta()`. +To understand the available sources better, use `covidcast_epidata()` and `covidcast_meta()`. + ```{r} covidcast_epidata() ``` + For example, let's see what kind of smoothed signals come out of the [facebook survey](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/fb-survey.html) source: + ```{r} cm <- covidcast_meta() %>% fetch_tbl() %>% dplyr::filter(grepl("smoothed", signal), data_source == "fb-survey") ``` + grabbing the first smoothed signal as an example: + ```{r} cm[1, ] %>% print(width = 100) cm[1, "signal"] ``` + and actually fetching some data from this source + ```{r} covidcast( data_source = "fb-survey", @@ -59,8 +66,10 @@ covidcast( geo_values = "06059" ) %>% fetch_tbl() ``` + County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed more here: . The example above is for Orange County, California. Since `covidcast` is an endpoint which supports `*`, here is an example of its use: + ```{r} covidcast( data_source = "fb-survey", @@ -81,6 +90,7 @@ API docs: Example calls: + ```{r} covid_hosp_facility_lookup(city = "southlake") %>% fetch_tbl() ``` @@ -122,7 +132,7 @@ Example call: covid_hosp_state_timeseries(states = "MA", dates = "20200510") %>% fetch_tbl() ``` -## Flu Endpoints +## Flu Endpoints ### Delphi's ILINet forecasts @@ -172,6 +182,7 @@ Example call: ```{r} fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701)) %>% fetch_tbl() ``` + ### Fluview metadata Function reference: @@ -183,6 +194,7 @@ fluview_meta() %>% fetch_tbl() ``` ### Google Flu Trends data + API docs: Function reference: @@ -192,6 +204,7 @@ gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) %>% fetch_tbl() ``` ### KCDC ILI + API docs: Function reference: @@ -199,7 +212,9 @@ Function reference: % fetch_tbl() ``` + ### NIDSS Flu + API docs: Function reference: @@ -208,7 +223,8 @@ Function reference: % fetch_tbl() ``` -### ILI Nearby Nowcast +### ILI Nearby Nowcast + API docs: Function reference: @@ -232,6 +248,7 @@ dengue_nowcast(locations = "pr", epiweeks = epirange(201401, 202301)) %>% fetch_ ``` ### NIDSS dengue + API docs: Function reference: @@ -251,7 +268,9 @@ paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() ``` ## Other Endpoints + ### Wikipedia Access + API docs: Function reference: @@ -259,38 +278,11 @@ Function reference: ```{r} wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319)) %>% fetch_tbl() ``` + # Private methods These require private access keys to use. To actually run these locally, you will need to store these secrets in your `.Reviron` file, or set them as environmental variables. -### AFHSB metadata - -API docs: - -Function reference: - -Example call: -```{r, eval=FALSE} -pvt_meta_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB")) %>% fetch_classic() -``` -TODO internal server error -not on the server I was given access to - -### AFHSB data - -API docs: - -Function reference: - -Example call: - -```{r, eval=FALSE} -pvt_afhsb(auth = Sys.getenv("SECRET_API_AUTH_AFHSB"), locations = "mn", epiweeks = epirange(202002, 202110), flu_types = "flu1") %>% fetch_tbl() -``` - -TODO 500 internal server error -not on the server I was given access to - ### CDC API docs: @@ -298,6 +290,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_cdc(auth = Sys.getenv("SECRET_API_AUTH_CDC"), epiweeks = epirange(202003, 202304), locations = "ma") %>% fetch_tbl() ``` @@ -321,6 +314,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_ght(auth = Sys.getenv("SECRET_API_AUTH_GHT"), epiweeks = epirange(199301, 202304), locations = "ma", query = "how to get over the flu") %>% fetch_tbl() ``` @@ -332,6 +326,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) %>% fetch_classic() ``` @@ -343,9 +338,11 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "ma", epiweeks = epirange(199001, 202105)) %>% fetch_classic() ``` + TODO can't seem to get a relevant sample, the example in the reference section is borked. ### Quidel Covid and Influenza testing @@ -355,6 +352,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_quidel(auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` @@ -366,6 +364,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` @@ -377,6 +376,7 @@ API docs: Function reference: Example call: + ```{r, eval=FALSE} pvt_twitter(auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch_tbl() ``` From fde24cc3d42527951653059d839342f8abbde0fa Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Wed, 17 May 2023 22:18:30 -0700 Subject: [PATCH 06/13] missed ecdc_ili, adding that --- vignettes/endpoints.Rmd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index f57cc3da..bb3df25c 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -203,6 +203,16 @@ Function reference: gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) %>% fetch_tbl() ``` +### ECDC ILI + +API docs: + +Function reference: + +```{r} +ecdc_ili(regions = "Armenia", epiweeks = 201840) %>% fetch_tbl() +``` + ### KCDC ILI API docs: From 1864bbd7c9aadfe9f2f8a3851fef18345f3c10ff Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 18 May 2023 15:10:22 -0700 Subject: [PATCH 07/13] maybe don't leave todo's and load_all cruft --- vignettes/endpoints.Rmd | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index bb3df25c..7cd98499 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -15,8 +15,6 @@ knitr::opts_chunk$set(echo = TRUE) ```{r libraries} # remotes::install_github("cmu-delphi/epidatr") -#library(devtools) -#load_all("epidatr") library("epidatr") library("magrittr") library("dplyr") @@ -350,10 +348,9 @@ Function reference: % fetch_classic() -``` +pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "1", epiweeks = 201233) %>% fetch_classic() -TODO can't seem to get a relevant sample, the example in the reference section is borked. +``` ### Quidel Covid and Influenza testing From 5812d0fd5bd6ef83373428b35c5c5668ce9c7206 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 19 May 2023 14:19:45 -0700 Subject: [PATCH 08/13] `fetch_*` to `fetch` --- R/endpoints.R | 2 +- vignettes/endpoints.Rmd | 60 ++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index 92e890d5..6f023df8 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -747,7 +747,7 @@ covidcast <- function( #' #' @examples #' \donttest{ -#' delphi(system = "ec", epiweek = 201501) %>% fetch() +#' delphi(system = "ec", epiweek = 202006) %>% fetch() #' } #' @param system string. The system name to fetch. #' @param epiweek [`timeset`]. The epiweeks to fetch. diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index 7cd98499..b1ec027c 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -41,7 +41,7 @@ For example, let's see what kind of smoothed signals come out of the [facebook s ```{r} cm <- covidcast_meta() %>% - fetch_tbl() %>% + fetch() %>% dplyr::filter(grepl("smoothed", signal), data_source == "fb-survey") ``` @@ -62,7 +62,7 @@ covidcast( time_type = "day", time_values = epirange(20201221, 20201225), geo_values = "06059" -) %>% fetch_tbl() +) %>% fetch() ``` County geo_values are [FIPS codes](https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county) and are discussed more here: . The example above is for Orange County, California. @@ -76,7 +76,7 @@ covidcast( time_type = "day", time_values = epirange(20201221, 20201225), geo_values = "*" -) %>% fetch_tbl() +) %>% fetch() ``` ## Other Covid Endpoints @@ -90,17 +90,17 @@ Function reference: % fetch_tbl() +covid_hosp_facility_lookup(city = "southlake") %>% fetch() ``` ```{r} -covid_hosp_facility_lookup(state = "WY") %>% fetch_tbl() +covid_hosp_facility_lookup(state = "WY") %>% fetch() ``` A non-example (there is no city called New York in Wyoming); ```{r} -covid_hosp_facility_lookup(state = "WY", city = "New York") %>% fetch_tbl() +covid_hosp_facility_lookup(state = "WY", city = "New York") %>% fetch() ``` ### COVID-19 Hospitalization by Facility @@ -115,7 +115,7 @@ Example call: covid_hosp_facility( hospital_pks = "100075", collection_weeks = epirange(20200101, 20200501) -) %>% fetch_tbl() +) %>% fetch() ``` ### COVID-19 Hospitalization by State @@ -127,7 +127,7 @@ Function reference: % fetch_tbl() +covid_hosp_state_timeseries(states = "MA", dates = "20200510") %>% fetch() ``` ## Flu Endpoints @@ -141,7 +141,7 @@ Function reference: Example call: ```{r} -del <- delphi(system = "ec", epiweek = 201501) %>% fetch_classic() +del <- delphi(system = "ec", epiweek = 201501) %>% fetch() names(del$epidata$forecast) ``` @@ -154,7 +154,7 @@ Function reference: % fetch_tbl() +flusurv(locations = "ca", epiweeks = 202001) %>% fetch() ``` ### Fluview data @@ -166,7 +166,7 @@ Function reference: % fetch_tbl() +fluview(regions = "nat", epiweeks = epirange(201201, 202001)) %>% fetch() ``` ### Fluview virological data from clinical labs @@ -178,7 +178,7 @@ Function reference: % fetch_tbl() +fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701)) %>% fetch() ``` ### Fluview metadata @@ -188,7 +188,7 @@ Function reference: % fetch_tbl() +fluview_meta() %>% fetch() ``` ### Google Flu Trends data @@ -198,7 +198,7 @@ API docs: Function reference: ```{r} -gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) %>% fetch_tbl() +gft(locations = "hhs1", epiweeks = epirange(201201, 202001)) %>% fetch() ``` ### ECDC ILI @@ -208,7 +208,7 @@ API docs: Function reference: ```{r} -ecdc_ili(regions = "Armenia", epiweeks = 201840) %>% fetch_tbl() +ecdc_ili(regions = "Armenia", epiweeks = 201840) %>% fetch() ``` ### KCDC ILI @@ -218,7 +218,7 @@ API docs: Function reference: ```{r} -kcdc_ili(regions = "ROK", epiweeks = 200436) %>% fetch_tbl() +kcdc_ili(regions = "ROK", epiweeks = 200436) %>% fetch() ``` ### NIDSS Flu @@ -228,7 +228,7 @@ API docs: Function reference: ```{r} -nidss_flu(regions = "taipei", epiweeks = epirange(200901, 201301)) %>% fetch_tbl() +nidss_flu(regions = "taipei", epiweeks = epirange(200901, 201301)) %>% fetch() ``` ### ILI Nearby Nowcast @@ -238,7 +238,7 @@ API docs: Function reference: ```{r} -nowcast(locations = "ca", epiweeks = epirange(202201, 202319)) %>% fetch_tbl() +nowcast(locations = "ca", epiweeks = epirange(202201, 202319)) %>% fetch() ``` ## Dengue Endpoints @@ -252,7 +252,7 @@ Function reference: % fetch_tbl() +dengue_nowcast(locations = "pr", epiweeks = epirange(201401, 202301)) %>% fetch() ``` ### NIDSS dengue @@ -262,7 +262,7 @@ API docs: Function reference: ```{r} -nidss_dengue(locations = "taipei", epiweeks = epirange(200301, 201301)) %>% fetch_tbl() +nidss_dengue(locations = "taipei", epiweeks = epirange(200301, 201301)) %>% fetch() ``` ## PAHO Dengue @@ -272,7 +272,7 @@ API docs: Function reference: ```{r, eval=FALSE} -paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319)) %>% fetch_tbl() +paho_dengue(regions = "ca", epiweeks = epirange(200201, 202319)) %>% fetch() ``` ## Other Endpoints @@ -284,7 +284,7 @@ API docs: Function reference: ```{r} -wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319)) %>% fetch_tbl() +wiki(language = "en", articles = "influenza", epiweeks = epirange(202001, 202319)) %>% fetch() ``` # Private methods @@ -300,7 +300,7 @@ Function reference: % fetch_tbl() +pvt_cdc(auth = Sys.getenv("SECRET_API_AUTH_CDC"), epiweeks = epirange(202003, 202304), locations = "ma") %>% fetch() ``` ### Dengue Digital Surveillance Sensors @@ -312,7 +312,7 @@ Function reference: % fetch_tbl() +pvt_dengue_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "ght", locations = "ag", epiweeks = epirange(201404, 202004)) %>% fetch() ``` ### Google Health Trends @@ -324,7 +324,7 @@ Function reference: % fetch_tbl() +pvt_ght(auth = Sys.getenv("SECRET_API_AUTH_GHT"), epiweeks = epirange(199301, 202304), locations = "ma", query = "how to get over the flu") %>% fetch() ``` ### NoroSTAT metadata @@ -336,7 +336,7 @@ Function reference: % fetch_classic() +pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT")) %>% fetch() ``` ### NoroSTAT data @@ -348,7 +348,7 @@ Function reference: % fetch_classic() +pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "1", epiweeks = 201233) %>% fetch() ``` @@ -361,7 +361,7 @@ Function reference: % fetch_tbl() +pvt_quidel(auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"), locations = "hhs1", epiweeks = epirange(200301, 202105)) %>% fetch() ``` ### Sensors @@ -373,7 +373,7 @@ Function reference: % fetch_tbl() +pvt_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), names = "sar3", locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch() ``` ### Twitter @@ -385,5 +385,5 @@ Function reference: % fetch_tbl() +pvt_twitter(auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), locations = "nat", epiweeks = epirange(200301, 202105)) %>% fetch() ``` From 6835917c8a9084b2a41def1f6847ebc0fd898f07 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 19 May 2023 14:21:10 -0700 Subject: [PATCH 09/13] updating endpoints inputs --- R/endpoints.R | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index 6f023df8..e43ce224 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -6,7 +6,7 @@ #' \dontrun{ #' pvt_cdc( #' auth = "yourkey", -#' "fl,ca", +#' locations = "fl,ca", #' epirange(201501, 201601) #' ) %>% fetch() #' } @@ -62,6 +62,7 @@ pvt_cdc <- function(auth, locations, epiweeks) { #' @examples #' \donttest{ #' covid_hosp_facility_lookup(state = "fl") %>% fetch() +#' covid_hosp_facility_lookup(city = "southlake") %>% fetch() #' } #' @param state string. A two-letter character string state abbreviation. #' @param ccn string. A character string for facility CMS certification number. @@ -779,7 +780,7 @@ delphi <- function(system, epiweek) { #' @examples #' \dontrun{ #' dengue_nowcast( -#' locations = "?", +#' locations = "pr", #' epiweeks = epirange(201501, 202001) #' ) %>% fetch() #' } @@ -815,8 +816,8 @@ dengue_nowcast <- function(locations, epiweeks) { #' \dontrun{ #' pvt_dengue_sensors( #' auth = "yourkey", -#' names = "?", -#' locations = "?", +#' names = "ght", +#' locations = "ag", #' epiweeks = epirange(201501, 202001) #' ) %>% fetch() #' } @@ -1020,6 +1021,10 @@ fluview_clinical <- function(regions, epiweeks, issues = NULL, lag = NULL) { #' Fetch FluView metadata #' #' API docs: https://cmu-delphi.github.io/delphi-epidata/api/fluview_meta.html +#' @examples +#' \donttest{ +#' fluview_meta() %>% fetch() +#' } #' #' @return [`epidata_call`] #' @@ -1159,7 +1164,7 @@ gft <- function(locations, epiweeks) { #' auth = "yourkey", #' locations = "ca", #' epiweeks = epirange(201201, 202001), -#' query = "?" +#' query = "how to get over the flu" #' ) %>% fetch() #' } #' @param auth string. Restricted access key (not the same as API key). @@ -1199,7 +1204,7 @@ pvt_ght <- function(auth, locations, epiweeks, query) { #' TODO: find a non-trivial region #' @examples #' \dontrun{ -#' kcdc_ili(regions = "?", epiweeks = epirange(201201, 202001)) %>% fetch() +#' kcdc_ili(regions = "ROC", epiweeks = 200436) %>% fetch() #' } #' @param regions character vector. The regions to be fetched. #' @param epiweeks [`timeset`]. The epiweeks to be fetched. @@ -1244,6 +1249,10 @@ kcdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL) { #' #' API docs: https://cmu-delphi.github.io/delphi-epidata/api/meta_norostat.html #' +#' @examples +#' \donttest{ +#' pvt_meta_norostat(auth = "yourkey") %>% fetch() +#' } #' @param auth string. Restricted access key (not the same as API key). #' @return [`epidata_call`] #' @@ -1364,8 +1373,8 @@ nidss_flu <- function(regions, epiweeks, issues = NULL, lag = NULL) { #' \dontrun{ #' pvt_norostat( #' auth = "yourkey", -#' locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin", -#' epiweeks = epirange(201401, 201501) +#' locations = "1", +#' epiweeks = 201233 #' ) %>% fetch() #' } #' @param auth string. Your authentication key. From b70723fb99ee0ff270c489563b76fbf48040d129 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 19 May 2023 15:47:00 -0700 Subject: [PATCH 10/13] doc updates in the actual man files, whitespace --- man/covid_hosp_facility_lookup.Rd | 1 + man/delphi.Rd | 2 +- man/dengue_nowcast.Rd | 2 +- man/fluview_meta.Rd | 6 ++++++ man/kcdc_ili.Rd | 2 +- man/pvt_cdc.Rd | 2 +- man/pvt_dengue_sensors.Rd | 4 ++-- man/pvt_ght.Rd | 2 +- man/pvt_meta_norostat.Rd | 5 +++++ man/pvt_norostat.Rd | 4 ++-- vignettes/endpoints.Rmd | 25 +++++++++++++++++++------ 11 files changed, 40 insertions(+), 15 deletions(-) diff --git a/man/covid_hosp_facility_lookup.Rd b/man/covid_hosp_facility_lookup.Rd index b42e7c9d..a1caa5e6 100644 --- a/man/covid_hosp_facility_lookup.Rd +++ b/man/covid_hosp_facility_lookup.Rd @@ -42,6 +42,7 @@ For instance, specifying both city and state are not supported. \examples{ \donttest{ covid_hosp_facility_lookup(state = "fl") \%>\% fetch() +covid_hosp_facility_lookup(city = "southlake") \%>\% fetch() } } \seealso{ diff --git a/man/delphi.Rd b/man/delphi.Rd index 0361d1dc..abf78c3e 100644 --- a/man/delphi.Rd +++ b/man/delphi.Rd @@ -19,6 +19,6 @@ API docs: https://cmu-delphi.github.io/delphi-epidata/api/delphi.html } \examples{ \donttest{ -delphi(system = "ec", epiweek = 201501) \%>\% fetch() +delphi(system = "ec", epiweek = 202006) \%>\% fetch() } } diff --git a/man/dengue_nowcast.Rd b/man/dengue_nowcast.Rd index 760ac8ed..3cfd087e 100644 --- a/man/dengue_nowcast.Rd +++ b/man/dengue_nowcast.Rd @@ -23,7 +23,7 @@ TODO: what are valid locations here? \examples{ \dontrun{ dengue_nowcast( - locations = "?", + locations = "pr", epiweeks = epirange(201501, 202001) ) \%>\% fetch() } diff --git a/man/fluview_meta.Rd b/man/fluview_meta.Rd index 0cd8eaba..096db329 100644 --- a/man/fluview_meta.Rd +++ b/man/fluview_meta.Rd @@ -12,3 +12,9 @@ fluview_meta() \description{ API docs: https://cmu-delphi.github.io/delphi-epidata/api/fluview_meta.html } +\examples{ +\donttest{ +fluview_meta() \%>\% fetch() +} + +} diff --git a/man/kcdc_ili.Rd b/man/kcdc_ili.Rd index 45aef01e..ea374540 100644 --- a/man/kcdc_ili.Rd +++ b/man/kcdc_ili.Rd @@ -28,6 +28,6 @@ TODO: find a non-trivial region } \examples{ \dontrun{ -kcdc_ili(regions = "?", epiweeks = epirange(201201, 202001)) \%>\% fetch() +kcdc_ili(regions = "ROC", epiweeks = 200436) \%>\% fetch() } } diff --git a/man/pvt_cdc.Rd b/man/pvt_cdc.Rd index 353202c2..7d6b6373 100644 --- a/man/pvt_cdc.Rd +++ b/man/pvt_cdc.Rd @@ -23,7 +23,7 @@ API docs: https://cmu-delphi.github.io/delphi-epidata/api/cdc.html \dontrun{ pvt_cdc( auth = "yourkey", - "fl,ca", + locations = "fl,ca", epirange(201501, 201601) ) \%>\% fetch() } diff --git a/man/pvt_dengue_sensors.Rd b/man/pvt_dengue_sensors.Rd index 78e2facb..6212e04c 100644 --- a/man/pvt_dengue_sensors.Rd +++ b/man/pvt_dengue_sensors.Rd @@ -29,8 +29,8 @@ TODO: what are valid locations and names? \dontrun{ pvt_dengue_sensors( auth = "yourkey", - names = "?", - locations = "?", + names = "ght", + locations = "ag", epiweeks = epirange(201501, 202001) ) \%>\% fetch() } diff --git a/man/pvt_ght.Rd b/man/pvt_ght.Rd index fdfec8bd..89ede2b1 100644 --- a/man/pvt_ght.Rd +++ b/man/pvt_ght.Rd @@ -30,7 +30,7 @@ pvt_ght( auth = "yourkey", locations = "ca", epiweeks = epirange(201201, 202001), - query = "?" + query = "how to get over the flu" ) \%>\% fetch() } } diff --git a/man/pvt_meta_norostat.Rd b/man/pvt_meta_norostat.Rd index 63dbfc55..80af7c96 100644 --- a/man/pvt_meta_norostat.Rd +++ b/man/pvt_meta_norostat.Rd @@ -15,3 +15,8 @@ pvt_meta_norostat(auth) \description{ API docs: https://cmu-delphi.github.io/delphi-epidata/api/meta_norostat.html } +\examples{ +\donttest{ +pvt_meta_norostat(auth = "yourkey") \%>\% fetch() +} +} diff --git a/man/pvt_norostat.Rd b/man/pvt_norostat.Rd index eb706181..5b2fbe32 100644 --- a/man/pvt_norostat.Rd +++ b/man/pvt_norostat.Rd @@ -23,8 +23,8 @@ API docs: https://cmu-delphi.github.io/delphi-epidata/api/norostat.html \dontrun{ pvt_norostat( auth = "yourkey", - locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin", - epiweeks = epirange(201401, 201501) + locations = "1", + epiweeks = 201233 ) \%>\% fetch() } } diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index b1ec027c..a18fa678 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -14,7 +14,6 @@ knitr::opts_chunk$set(echo = TRUE) ``` ```{r libraries} -# remotes::install_github("cmu-delphi/epidatr") library("epidatr") library("magrittr") library("dplyr") @@ -312,7 +311,11 @@ Function reference: % fetch() +pvt_dengue_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), + names = "ght", + locations = "ag", + epiweeks = epirange(201404, 202004) + ) %>% fetch() ``` ### Google Health Trends @@ -324,7 +327,11 @@ Function reference: % fetch() +pvt_ght(auth = Sys.getenv("SECRET_API_AUTH_GHT"), + epiweeks = epirange(199301, 202304), + locations = "ma", + query = "how to get over the flu" + ) %>% fetch() ``` ### NoroSTAT metadata @@ -349,7 +356,6 @@ Example call: ```{r, eval=FALSE} pvt_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"), locations = "1", epiweeks = 201233) %>% fetch() - ``` ### Quidel Covid and Influenza testing @@ -373,7 +379,11 @@ Function reference: % fetch() +pvt_sensors(auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), + names = "sar3", + locations = "nat", + epiweeks = epirange(200301, 202105) + ) %>% fetch() ``` ### Twitter @@ -385,5 +395,8 @@ Function reference: % fetch() +pvt_twitter(auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), + locations = "nat", + epiweeks = epirange(200301, 202105) + ) %>% fetch() ``` From 392000ae40239a0b1212c7e405922247c64c54a1 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Tue, 23 May 2023 14:31:09 -0700 Subject: [PATCH 11/13] happy linter and .Rbuildignore --- .Rbuildignore | 4 +++- vignettes/endpoints.Rmd | 42 ++++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 0b4b1542..c6d724be 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ +^renv$ +^renv\.lock$ ^.*\.Rproj$ ^.*\..Rcheck$ ^\.Rproj\.user$ @@ -18,4 +20,4 @@ ^venv$ ^.venv$ ^env$ -^.env$ \ No newline at end of file +^.env$ diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index a18fa678..970555a3 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -311,11 +311,12 @@ Function reference: % fetch() +pvt_dengue_sensors( + auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), + names = "ght", + locations = "ag", + epiweeks = epirange(201404, 202004) +) %>% fetch() ``` ### Google Health Trends @@ -327,11 +328,12 @@ Function reference: % fetch() +pvt_ght( + auth = Sys.getenv("SECRET_API_AUTH_GHT"), + epiweeks = epirange(199301, 202304), + locations = "ma", + query = "how to get over the flu" +) %>% fetch() ``` ### NoroSTAT metadata @@ -379,11 +381,12 @@ Function reference: % fetch() +pvt_sensors( + auth = Sys.getenv("SECRET_API_AUTH_SENSORS"), + names = "sar3", + locations = "nat", + epiweeks = epirange(200301, 202105) +) %>% fetch() ``` ### Twitter @@ -395,8 +398,9 @@ Function reference: % fetch() +pvt_twitter( + auth = Sys.getenv("SECRET_API_AUTH_TWITTER"), + locations = "nat", + epiweeks = epirange(200301, 202105) +) %>% fetch() ``` From e442b19ff0e54adea57c10edd59c6b81a2e3e515 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 26 May 2023 10:50:44 -0700 Subject: [PATCH 12/13] vignette updates need to go in the docs --- R/endpoints.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index e43ce224..d8d50c51 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -748,7 +748,7 @@ covidcast <- function( #' #' @examples #' \donttest{ -#' delphi(system = "ec", epiweek = 202006) %>% fetch() +#' delphi(system = "ec", epiweek = 201501) %>% fetch() #' } #' @param system string. The system name to fetch. #' @param epiweek [`timeset`]. The epiweeks to fetch. @@ -1204,7 +1204,7 @@ pvt_ght <- function(auth, locations, epiweeks, query) { #' TODO: find a non-trivial region #' @examples #' \dontrun{ -#' kcdc_ili(regions = "ROC", epiweeks = 200436) %>% fetch() +#' kcdc_ili(regions = "ROK", epiweeks = 200436) %>% fetch() #' } #' @param regions character vector. The regions to be fetched. #' @param epiweeks [`timeset`]. The epiweeks to be fetched. From 0e5f3993a6d4a89e8a4bf0d0feed3b2ef3111777 Mon Sep 17 00:00:00 2001 From: "Logan C. Brooks" Date: Fri, 26 May 2023 11:55:33 -0700 Subject: [PATCH 13/13] docs(endpoints.Rmd): update `delphi` example for current `fetch()` `fetch()` now raises epidata errors and warnings and returns `$epidata`, rather than the result-message-epidata triplet; update vignette to remove `$epidata`. Also, index to get the first and only forecast returned. --- vignettes/endpoints.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index 970555a3..07968dac 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -141,7 +141,7 @@ Example call: ```{r} del <- delphi(system = "ec", epiweek = 201501) %>% fetch() -names(del$epidata$forecast) +names(del[[1L]]$forecast) ``` ### FluSurv hospitalization data