Browse Source

initial commit

master
boB Rudis 5 years ago
parent
commit
7dc9eb67a3
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 9
      DESCRIPTION
  3. 2
      LICENSE
  4. 21
      LICENSE.md
  5. 23
      NAMESPACE
  6. 77
      R/aaa.R
  7. 23
      R/delphi-articles.R
  8. 28
      R/delphi-cities.R
  9. 9
      R/delphi-regions.R
  10. 11
      R/delphi-states.R
  11. 10
      R/delphiepidata-package.R
  12. 457
      R/f.R
  13. 31
      README.Rmd
  14. 77
      README.md
  15. 18
      man/cdc.Rd
  16. 16
      man/delphi.Rd
  17. 14
      man/delphi_articles.Rd
  18. 14
      man/delphi_regions.Rd
  19. 14
      man/delphi_states.Rd
  20. 11
      man/delphiepidata.Rd
  21. 16
      man/dengue_nowcast.Rd
  22. 20
      man/dengue_sensors.Rd
  23. 14
      man/deplhi_cities.Rd
  24. 20
      man/flusurv.Rd
  25. 22
      man/fluview.Rd
  26. 20
      man/fluview_clinical.Rd
  27. 16
      man/gft.Rd
  28. 20
      man/ght.Rd
  29. 11
      man/meta.Rd
  30. 14
      man/meta_norostat.Rd
  31. 16
      man/nidss_dengue.Rd
  32. 20
      man/nidss_flu.Rd
  33. 18
      man/norostat.Rd
  34. 16
      man/nowcast.Rd
  35. 18
      man/quidel.Rd
  36. 20
      man/sensors.Rd
  37. 20
      man/twitter.Rd
  38. 20
      man/wiki.Rd

1
.Rbuildignore

@ -13,3 +13,4 @@
^tmp$
^notes$
^\.gitlab-ci\.yml$
^LICENSE\.md$

9
DESCRIPTION

@ -1,6 +1,6 @@
Package: delphiepidata
Type: Package
Title: delphiepidata title goes here otherwise CRAN checks fail
Title: Query the 'CMU' 'DELPHI' Epidemiological Data 'API'
Version: 0.1.0
Date: 2019-05-29
Authors@R: c(
@ -8,11 +8,14 @@ Authors@R: c(
comment = c(ORCID = "0000-0001-5670-2640"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A good description goes here otherwise CRAN checks fail.
Description: The 'CMU' 'DELPHI' (<https://delphi.midas.cs.cmu.edu/>) service
provides an aggregated, central point of access to influenza-like
illness ('ILI') related data sources. Methods are provided to query
all supported endpoints.
URL: https://gitlab.com/hrbrmstr/delphiepidata
BugReports: https://gitlab.com/hrbrmstr/delphiepidata/issues
Encoding: UTF-8
License: AGPL
License: MIT + file LICENSE
Suggests:
testthat,
covr

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2019 Bob Rudis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

23
NAMESPACE

@ -1,4 +1,27 @@
# Generated by roxygen2: do not edit by hand
export(cdc)
export(delphi)
export(delphi_articles)
export(delphi_regions)
export(delphi_states)
export(dengue_nowcast)
export(dengue_sensors)
export(deplhi_cities)
export(flusurv)
export(fluview)
export(fluview_clinical)
export(gft)
export(ght)
export(meta)
export(meta_norostat)
export(nidss_dengue)
export(nidss_flu)
export(norostat)
export(nowcast)
export(quidel)
export(sensors)
export(twitter)
export(wiki)
import(httr)
importFrom(jsonlite,fromJSON)

77
R/aaa.R

@ -0,0 +1,77 @@
httr::user_agent(
sprintf(
"delphiepidata package v%s: (<%s>)",
utils::packageVersion("delphiepidata"),
utils::packageDescription("delphiepidata")$URL
)
) -> .DELPHI_UA
# A module for DELPHI's Epidata API.
#
# https://github.com/cmu-delphi/delphi-epidata
# API base url
BASE_URL <- 'https://delphi.midas.cs.cmu.edu/epidata/api.php'
# Helper function to cast values and/or ranges to strings
.listitem <- function(value) {
if(is.list(value) && 'from' %in% names(value) && 'to' %in% names(value)) {
return(paste0(toString(value$from), '-', toString(value$to)))
} else {
return(toString(value))
}
}
# Helper function to build a list of values and/or ranges
.list <- function(values) {
if(!is.list(values) || ('from' %in% names(values) && 'to' %in% names(values))) {
values <- list(values)
}
return(
paste(
vapply(values, .listitem, character(1)),
# sapply(values, .listitem),
collapse = ','
)
)
}
# Helper function to request and parse epidata
.request <- function(params) {
# API call
return(
httr::content(
httr::GET(
url = BASE_URL,
query = params,
.DELPHI_UA
),
as = 'parsed'
)
)
}
# Build a `range` object (ex: dates/epiweeks)
range <- function(from, to) {
if(to <= from) {
temp <- to
to <- from
from <- temp
}
return(
list(
from = from,
to = to
)
)
}

23
R/delphi-articles.R

@ -0,0 +1,23 @@
#' Supported Wikipedia Article Titles
#'
#' @docType data
#' @export
c(
'amantadine', 'antiviral_drugs', 'avian_influenza', 'canine_influenza',
'cat_flu', 'chills', 'common_cold', 'cough', 'equine_influenza',
'fatigue_(medical)', 'fever', 'flu_season', 'gastroenteritis',
'headache', 'hemagglutinin_(influenza)', 'human_flu', 'influenza',
'influenzalike_illness', 'influenzavirus_a', 'influenzavirus_c',
'influenza_a_virus', 'influenza_a_virus_subtype_h10n7',
'influenza_a_virus_subtype_h1n1', 'influenza_a_virus_subtype_h1n2',
'influenza_a_virus_subtype_h2n2', 'influenza_a_virus_subtype_h3n2',
'influenza_a_virus_subtype_h3n8', 'influenza_a_virus_subtype_h5n1',
'influenza_a_virus_subtype_h7n2', 'influenza_a_virus_subtype_h7n3',
'influenza_a_virus_subtype_h7n7', 'influenza_a_virus_subtype_h7n9',
'influenza_a_virus_subtype_h9n2', 'influenza_b_virus', 'influenza_pandemic',
'influenza_prevention', 'influenza_vaccine', 'malaise', 'myalgia',
'nasal_congestion', 'nausea', 'neuraminidase_inhibitor', 'orthomyxoviridae',
'oseltamivir', 'paracetamol', 'rhinorrhea', 'rimantadine', 'shivering',
'sore_throat', 'swine_influenza', 'viral_neuraminidase', 'viral_pneumonia',
'vomiting', 'zanamivir'
) -> delphi_articles

28
R/delphi-cities.R

@ -0,0 +1,28 @@
#' Supported Cities
#'
#' @docType data
#' @export
c(
'Albany_NY', 'Albuquerque_NM', 'Anchorage_AK', 'Arlington_VA',
'Atlanta_GA', 'Austin_TX', 'Baltimore_MD', 'Baton_Rouge_LA',
'Beaverton_OR', 'Bellevue_WA', 'Berkeley_CA', 'Birmingham_AL',
'Boise_ID', 'Boston_MA', 'Buffalo_NY', 'Cary_NC', 'Charlotte_NC',
'Chicago_IL', 'Cleveland_OH', 'Colorado_Springs_CO', 'Columbia_SC',
'Columbus_OH', 'Dallas_TX', 'Dayton_OH', 'Denver_CO', 'Des_Moines_IA',
'Durham_NC', 'Eugene_OR', 'Fresno_CA', 'Ft_Worth_TX', 'Gainesville_FL',
'Grand_Rapids_MI', 'Greensboro_NC', 'Greenville_SC', 'Honolulu_HI',
'Houston_TX', 'Indianapolis_IN', 'Irvine_CA', 'Irving_TX',
'Jacksonville_FL', 'Jackson_MS', 'Kansas_City_MO', 'Knoxville_TN',
'Las_Vegas_NV', 'Lexington_KY', 'Lincoln_NE', 'Little_Rock_AR',
'Los_Angeles_CA', 'Lubbock_TX', 'Madison_WI', 'Memphis_TN', 'Mesa_AZ',
'Miami_FL', 'Milwaukee_WI', 'Nashville_TN', 'Newark_NJ', 'New_Orleans_LA',
'New_York_NY', 'Norfolk_VA', 'Oakland_CA', 'Oklahoma_City_OK', 'Omaha_NE',
'Orlando_FL', 'Philadelphia_PA', 'Phoenix_AZ', 'Pittsburgh_PA', 'Plano_TX',
'Portland_OR', 'Providence_RI', 'Raleigh_NC', 'Reno_NV', 'Reston_VA',
'Richmond_VA', 'Rochester_NY', 'Roswell_GA', 'Sacramento_CA',
'Salt_Lake_City_UT', 'Santa_Clara_CA', 'San_Antonio_TX', 'San_Diego_CA',
'San_Francisco_CA', 'San_Jose_CA', 'Scottsdale_AZ', 'Seattle_WA',
'Somerville_MA', 'Spokane_WA', 'Springfield_MO', 'State_College_PA',
'St_Louis_MO', 'St_Paul_MN', 'Sunnyvale_CA', 'Tampa_FL', 'Tempe_AZ',
'Tucson_AZ', 'Tulsa_OK', 'Washington_DC', 'Wichita_KS'
) -> deplhi_cities

9
R/delphi-regions.R

@ -0,0 +1,9 @@
#' Supported Regions
#'
#' @docType data
#' @export
c(
'nat', 'hhs1', 'hhs2', 'hhs3', 'hhs4', 'hhs5', 'hhs6',
'hhs7', 'hhs8', 'hhs9', 'hhs10', 'cen1', 'cen2', 'cen3',
'cen4', 'cen5', 'cen6', 'cen7', 'cen8', 'cen9'
) -> delphi_regions

11
R/delphi-states.R

@ -0,0 +1,11 @@
#' Supported States
#'
#' @docType data
#' @export
c(
'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL',
'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA',
'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE',
'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI',
'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY'
) -> delphi_states

10
R/delphiepidata-package.R

@ -1,10 +1,18 @@
#' ...
#' Query the 'CMU' 'DELPHI' Epidemiological Data 'API'
#'
#' The 'CMU' 'DELPHI' (<https://delphi.midas.cs.cmu.edu/>) service
#' provides an aggregated, central point of access to influenza-like
#' illness ('ILI') related data sources. Methods are provided to query
#' all supported endpoints.
#'
#' - DELPHI API docs: <https://github.com/cmu-delphi/delphi-epidata>
#' - DELPHI: <https://delphi.midas.cs.cmu.edu/>
#' - URL: <https://gitlab.com/hrbrmstr/delphiepidata>
#' - BugReports: <https://gitlab.com/hrbrmstr/delphiepidata/issues>
#'
#' @md
#' @name delphiepidata
#' @keywords internal
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import httr

457
R/f.R

@ -0,0 +1,457 @@
#' Fetch FluView data
#'
#' @param regions a `list` of [delphi_regions]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param issues a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param lag a number of weeks
#' @param auth password for private imputed data
#' @export
fluview <- function(regions, epiweeks, issues, lag, auth) {
# Check parameters
if(missing(regions) || missing(epiweeks)) {
stop('`regions` and `epiweeks` are both required')
}
if(!missing(issues) && !missing(lag)) {
stop('`issues` and `lag` are mutually exclusive')
}
# Set up request
params <- list(
source = 'fluview',
regions = .list(regions),
epiweeks = .list(epiweeks)
)
if (!missing(issues)) params$issues <- .list(issues)
if (!missing(lag)) params$lag <- lag
if (!missing(auth)) params$auth <- auth
# Make the API call
return(.request(params))
}
#' Fetch FluView virological data
#'
#' @param regions a `list` of [delphi_regions]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param issues a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param lag a number of weeks
#' @export
fluview_clinical <- function(regions, epiweeks, issues, lag) {
# Check parameters
if(missing(regions) || missing(epiweeks)) {
stop('`regions` and `epiweeks` are both required')
}
if(!missing(issues) && !missing(lag)) {
stop('`issues` and `lag` are mutually exclusive')
}
# Set up request
params <- list(
source = 'fluview_clinical',
regions = .list(regions),
epiweeks = .list(epiweeks)
)
if(!missing(issues)) {
params$issues <- .list(issues)
}
if(!missing(lag)) {
params$lag <- lag
}
# Make the API call
return(.request(params))
}
#' Fetch FluSurv data
#'
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param issues a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param lag a number of weeks
#' @export
flusurv <- function(locations, epiweeks, issues, lag) {
# Check parameters
if(missing(locations) || missing(epiweeks)) {
stop('`locations` and `epiweeks` are both required')
}
if(!missing(issues) && !missing(lag)) {
stop('`issues` and `lag` are mutually exclusive')
}
# Set up request
params <- list(
source = 'flusurv',
locations = .list(locations),
epiweeks = .list(epiweeks)
)
if(!missing(issues)) {
params$issues <- .list(issues)
}
if(!missing(lag)) {
params$lag <- lag
}
# Make the API call
return(.request(params))
}
#' Fetch Google Flu Trends data
#'
#' @param locations a `list` of [delphi_regions], [dephi_states], and/or [delphi_cities]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
gft <- function(locations, epiweeks) {
# Check parameters
if(missing(locations) || missing(epiweeks)) {
stop('`locations` and `epiweeks` are both required')
}
# Set up request
params <- list(
source = 'gft',
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch Google Health Trends data
#'
#' @param auth authentication token
#' @param locations a `list` of [delphi_regions] and/or [delphi_cities]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param query google query
#' @export
ght <- function(auth, locations, epiweeks, query) {
# Check parameters
if(missing(auth) || missing(locations) || missing(epiweeks) || missing(query)) {
stop('`auth`, `locations`, `epiweeks`, and `query` are all required')
}
# Set up request
params <- list(
source = 'ght',
auth = auth,
locations = .list(locations),
epiweeks = .list(epiweeks),
query = query
)
# Make the API call
return(.request(params))
}
#' Fetch HealthTweets data
#'
#' @param auth twitter auth token
#' @param locations a `list` of [delphi_regions] and/or [delphi_cities]
#' @param dates a `list` of dates (`YYYYMMDD` format)
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
twitter <- function(auth, locations, dates, epiweeks) {
# Check parameters
if(missing(auth) || missing(locations)) {
stop('`auth` and `locations` are both required')
}
if(!xor(missing(dates), missing(epiweeks))) {
stop('exactly one of `dates` and `epiweeks` is required')
}
# Set up request
params <- list(
source = 'twitter',
auth = auth,
locations = .list(locations)
)
if(!missing(dates)) {
params$dates <- .list(dates)
}
if(!missing(epiweeks)) {
params$epiweeks <- .list(epiweeks)
}
# Make the API call
return(.request(params))
}
#' Fetch Wikipedia access data
#'
#' @param articles a `list` of [delphi_articles]
#' @param dates a `list` of dates (`YYYYMMDD` format)
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param hours a `list` of hours
#' @export
wiki <- function(articles, dates, epiweeks, hours) {
# Check parameters
if(missing(articles)) {
stop('`articles` is required')
}
if(!xor(missing(dates), missing(epiweeks))) {
stop('exactly one of `dates` and `epiweeks` is required')
}
# Set up request
params <- list(
source = 'wiki',
articles = .list(articles)
)
if(!missing(dates)) {
params$dates <- .list(dates)
}
if(!missing(epiweeks)) {
params$epiweeks <- .list(epiweeks)
}
if(!missing(hours)) {
params$hours <- .list(hours)
}
# Make the API call
return(.request(params))
}
#' Fetch CDC page hits
#'
#' @param auth auth token
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @export
cdc <- function(auth, epiweeks, locations) {
# Check parameters
if(missing(auth) || missing(epiweeks) || missing(locations)) {
stop('`auth`, `epiweeks`, and `locations` are all required')
}
# Set up request
params <- list(
source = 'cdc',
auth = auth,
epiweeks = .list(epiweeks),
locations = .list(locations)
)
# Make the API call
return(.request(params))
}
#' Fetch Quidel data
#'
#' @param auth auth token
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @export
quidel <- function(auth, epiweeks, locations) {
# Check parameters
if(missing(auth) || missing(epiweeks) || missing(locations)) {
stop('`auth`, `epiweeks`, and `locations` are all required')
}
# Set up request
params <- list(
source = 'quidel',
auth = auth,
epiweeks = .list(epiweeks),
locations = .list(locations)
)
# Make the API call
return(.request(params))
}
#' Fetch NoroSTAT data (point data, no min/max)
#'
#' @param auth auth token
#' @param location a single [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
norostat <- function(auth, location, epiweeks) {
# Check parameters
if(missing(auth) || missing(location) || missing(epiweeks)) {
stop('`auth`, `location`, and `epiweeks` are all required')
}
# Set up request
params <- list(
source = 'norostat',
auth = auth,
location = location,
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch NoroSTAT metadata
#'
#' @param auth auth token
#' @export
meta_norostat <- function(auth) {
# Check parameters
if(missing(auth)) {
stop('`auth` is required')
}
# Set up request
params <- list(
source = 'meta_norostat',
auth = auth
)
# Make the API call
return(.request(params))
}
#' Fetch NIDSS flu data
#'
#' @param regions a `list` of [delphi_regions]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @param issues a `list` of issues
#' @param lag a number of weeks
#' @export
nidss_flu <- function(regions, epiweeks, issues, lag) {
# Check parameters
if(missing(regions) || missing(epiweeks)) {
stop('`regions` and `epiweeks` are both required')
}
if(!missing(issues) && !missing(lag)) {
stop('`issues` and `lag` are mutually exclusive')
}
# Set up request
params <- list(
source = 'nidss_flu',
regions = .list(regions),
epiweeks = .list(epiweeks)
)
if(!missing(issues)) {
params$issues <- .list(issues)
}
if(!missing(lag)) {
params$lag <- lag
}
# Make the API call
return(.request(params))
}
#' Fetch NIDSS dengue data
#'
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
nidss_dengue <- function(locations, epiweeks) {
# Check parameters
if(missing(locations) || missing(epiweeks)) {
stop('`locations` and `epiweeks` are both required')
}
# Set up request
params <- list(
source = 'nidss_dengue',
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch Delphi's forecast
#'
#' @param system (not sure)
#' @param epiweek an epiweek (fomat `YYYYWW`)
#' @export
delphi <- function(system, epiweek) {
# Check parameters
if(missing(system) || missing(epiweek)) {
stop('`system` and `epiweek` are both required')
}
# Set up request
params <- list(
source = 'delphi',
system = system,
epiweek = epiweek
)
# Make the API call
return(.request(params))
}
#' Fetch Delphi's digital surveillance sensors
#'
#' @param auth auth token
#' @param names sensor name?
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
sensors <- function(auth, names, locations, epiweeks) {
# Check parameters
if(missing(auth) || missing(names) || missing(locations) || missing(epiweeks)) {
stop('`auth`, `names`, `locations`, and `epiweeks` are all required')
}
# Set up request
params <- list(
source = 'sensors',
auth = auth,
names = .list(names),
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch Delphi's digital surveillance sensors
#'
#' @param auth auth token
#' @param names sensor names?
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
dengue_sensors <- function(auth, names, locations, epiweeks) {
# Check parameters
if(missing(auth) || missing(names) || missing(locations) || missing(epiweeks)) {
stop('`auth`, `names`, `locations`, and `epiweeks` are all required')
}
# Set up request
params <- list(
source = 'dengue_sensors',
auth = auth,
names = .list(names),
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch Delphi's wILI nowcast
#'
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
nowcast <- function(locations, epiweeks) {
# Check parameters
if(missing(locations) || missing(epiweeks)) {
stop('`locations` and `epiweeks` are both required')
}
# Set up request
params <- list(
source = 'nowcast',
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch Delphi's PAHO Dengue nowcast
#'
#' @param locations a `list` of [delphi_regions] and/or [dephi_states]
#' @param epiweeks a `list` of epiweeks (format for an epiweek is `YYYYWW`)
#' @export
dengue_nowcast <- function(locations, epiweeks) {
# Check parameters
if(missing(locations) || missing(epiweeks)) {
stop('`locations` and `epiweeks` are both required')
}
# Set up request
params <- list(
source = 'dengue_nowcast',
locations = .list(locations),
epiweeks = .list(epiweeks)
)
# Make the API call
return(.request(params))
}
#' Fetch API metadata
#'
#' @export
meta <- function() {
return(.request(list(source='meta')))
}

31
README.Rmd

@ -14,18 +14,47 @@ options(width=120)
# delphiepidata
Query the 'CMU' 'DELPHI' Epidemiological Data 'API'
## Description
The 'CMU' 'DELPHI' (<https://delphi.midas.cs.cmu.edu/>) service provides an aggregated, central point of access to influenza-like illness ('ILI') related data sources. Methods are provided to query all supported endpoints.
- DELPHI API docs: <https://github.com/cmu-delphi/delphi-epidata>
- DELPHI: <https://delphi.midas.cs.cmu.edu/>
- URL: <https://gitlab.com/hrbrmstr/delphiepidata>
- BugReports: <https://gitlab.com/hrbrmstr/delphiepidata/issues>
## What's Inside The Tin
The following functions are implemented:
- `cdc`: Fetch CDC page hits
- `delphi`: Fetch Delphi's forecast
- `dengue_nowcast`: Fetch Delphi's PAHO Dengue nowcast
- `dengue_sensors`: Fetch Delphi's digital surveillance sensors
- `flusurv`: Fetch FluSurv data
- `fluview`: Fetch FluView data
- `fluview_clinical`: Fetch FluView virological data
- `gft`: Fetch Google Flu Trends data
- `ght`: Fetch Google Health Trends data
- `meta`: Fetch API metadata
- `meta_norostat`: Fetch NoroSTAT metadata
- `nidss_dengue`: Fetch NIDSS dengue data
- `nidss_flu`: Fetch NIDSS flu data
- `norostat`: Fetch NoroSTAT data (point data, no min/max)
- `nowcast`: Fetch Delphi's wILI nowcast
- `quidel`: Fetch Quidel data
- `sensors`: Fetch Delphi's digital surveillance sensors
- `twitter`: Fetch HealthTweets data
- `wiki`: Fetch Wikipedia access data
## Installation
```{r install-ex, eval=FALSE}
devtools::install_git("https://sr.ht.com/~hrbrmstr/delphiepidata.git")
# or
devtools::install_git("https://gitlab.com/hrbrmstr/delphiepidata.git")
devtools::install_gitlab("hrbrmstr/delphiepidata")
# or (if you must)
devtools::install_github("hrbrmstr/delphiepidata")
```

77
README.md

@ -1,2 +1,79 @@
[![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/delphiepidata.svg?branch=master)](https://travis-ci.org/hrbrmstr/delphiepidata)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/delphiepidata/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/delphiepidata)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/delphiepidata)](https://cran.r-project.org/package=delphiepidata)
# delphiepidata
Query the ‘CMU’ ‘DELPHI’ Epidemiological Data ‘API’
## Description
The ‘CMU’ ‘DELPHI’ (<https://delphi.midas.cs.cmu.edu/>) service provides
an aggregated, central point of access to influenza-like illness (‘ILI’)
related data sources. Methods are provided to query all supported
endpoints.
- DELPHI API docs: <https://github.com/cmu-delphi/delphi-epidata>
- DELPHI: <https://delphi.midas.cs.cmu.edu/>
- URL: <https://gitlab.com/hrbrmstr/delphiepidata>
- BugReports: <https://gitlab.com/hrbrmstr/delphiepidata/issues>
## What’s Inside The Tin
The following functions are implemented:
- `cdc`: Fetch CDC page hits
- `delphi`: Fetch Delphi’s forecast
- `dengue_nowcast`: Fetch Delphi’s PAHO Dengue nowcast
- `dengue_sensors`: Fetch Delphi’s digital surveillance sensors
- `flusurv`: Fetch FluSurv data
- `fluview`: Fetch FluView data
- `fluview_clinical`: Fetch FluView virological data
- `gft`: Fetch Google Flu Trends data
- `ght`: Fetch Google Health Trends data
- `meta`: Fetch API metadata
- `meta_norostat`: Fetch NoroSTAT metadata
- `nidss_dengue`: Fetch NIDSS dengue data
- `nidss_flu`: Fetch NIDSS flu data
- `norostat`: Fetch NoroSTAT data (point data, no min/max)
- `nowcast`: Fetch Delphi’s wILI nowcast
- `quidel`: Fetch Quidel data
- `sensors`: Fetch Delphi’s digital surveillance sensors
- `twitter`: Fetch HealthTweets data
- `wiki`: Fetch Wikipedia access data
## Installation
``` r
devtools::install_git("https://sr.ht.com/~hrbrmstr/delphiepidata.git")
# or
devtools::install_gitlab("hrbrmstr/delphiepidata")
# or (if you must)
devtools::install_github("hrbrmstr/delphiepidata")
```
## Usage
``` r
library(delphiepidata)
# current version
packageVersion("delphiepidata")
## [1] '0.1.0'
```
## delphiepidata Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | --: | --: | ---: | ----------: | --: | -------: | ---: |
| R | 9 | 0.9 | 374 | 0.98 | 45 | 0.7 | 206 | 0.79 |
| Rmd | 1 | 0.1 | 8 | 0.02 | 19 | 0.3 | 54 | 0.21 |
## Code of Conduct
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.

18
man/cdc.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{cdc}
\alias{cdc}
\title{Fetch CDC page hits}
\usage{
cdc(auth, epiweeks, locations)
}
\arguments{
\item{auth}{auth token}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
}
\description{
Fetch CDC page hits
}

16
man/delphi.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{delphi}
\alias{delphi}
\title{Fetch Delphi's forecast}
\usage{
delphi(system, epiweek)
}
\arguments{
\item{system}{(not sure)}
\item{epiweek}{an epiweek (fomat \code{YYYYWW})}
}
\description{
Fetch Delphi's forecast
}

14
man/delphi_articles.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/delphi-articles.R
\docType{data}
\name{delphi_articles}
\alias{delphi_articles}
\title{Supported Wikipedia Article Titles}
\format{An object of class \code{character} of length 54.}
\usage{
delphi_articles
}
\description{
Supported Wikipedia Article Titles
}
\keyword{datasets}

14
man/delphi_regions.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/delphi-regions.R
\docType{data}
\name{delphi_regions}
\alias{delphi_regions}
\title{Supported Regions}
\format{An object of class \code{character} of length 20.}
\usage{
delphi_regions
}
\description{
Supported Regions
}
\keyword{datasets}

14
man/delphi_states.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/delphi-states.R
\docType{data}
\name{delphi_states}
\alias{delphi_states}
\title{Supported States}
\format{An object of class \code{character} of length 51.}
\usage{
delphi_states
}
\description{
Supported States
}
\keyword{datasets}

11
man/delphiepidata.Rd

@ -4,9 +4,17 @@
\name{delphiepidata}
\alias{delphiepidata}
\alias{delphiepidata-package}
\title{...}
\title{Query the 'CMU' 'DELPHI' Epidemiological Data 'API'}
\description{
The 'CMU' 'DELPHI' (\url{https://delphi.midas.cs.cmu.edu/}) service
provides an aggregated, central point of access to influenza-like
illness ('ILI') related data sources. Methods are provided to query
all supported endpoints.
}
\details{
\itemize{
\item DELPHI API docs: \url{https://github.com/cmu-delphi/delphi-epidata}
\item DELPHI: \url{https://delphi.midas.cs.cmu.edu/}
\item URL: \url{https://gitlab.com/hrbrmstr/delphiepidata}
\item BugReports: \url{https://gitlab.com/hrbrmstr/delphiepidata/issues}
}
@ -14,3 +22,4 @@
\author{
Bob Rudis (bob@rud.is)
}
\keyword{internal}

16
man/dengue_nowcast.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{dengue_nowcast}
\alias{dengue_nowcast}
\title{Fetch Delphi's PAHO Dengue nowcast}
\usage{
dengue_nowcast(locations, epiweeks)
}
\arguments{
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch Delphi's PAHO Dengue nowcast
}

20
man/dengue_sensors.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{dengue_sensors}
\alias{dengue_sensors}
\title{Fetch Delphi's digital surveillance sensors}
\usage{
dengue_sensors(auth, names, locations, epiweeks)
}
\arguments{
\item{auth}{auth token}
\item{names}{sensor names?}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch Delphi's digital surveillance sensors
}

14
man/deplhi_cities.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/delphi-cities.R
\docType{data}
\name{deplhi_cities}
\alias{deplhi_cities}
\title{Supported Cities}
\format{An object of class \code{character} of length 97.}
\usage{
deplhi_cities
}
\description{
Supported Cities
}
\keyword{datasets}

20
man/flusurv.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{flusurv}
\alias{flusurv}
\title{Fetch FluSurv data}
\usage{
flusurv(locations, epiweeks, issues, lag)
}
\arguments{
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{issues}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{lag}{a number of weeks}
}
\description{
Fetch FluSurv data
}

22
man/fluview.Rd

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{fluview}
\alias{fluview}
\title{Fetch FluView data}
\usage{
fluview(regions, epiweeks, issues, lag, auth)
}
\arguments{
\item{regions}{a \code{list} of \link{delphi_regions}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{issues}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{lag}{a number of weeks}
\item{auth}{password for private imputed data}
}
\description{
Fetch FluView data
}

20
man/fluview_clinical.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{fluview_clinical}
\alias{fluview_clinical}
\title{Fetch FluView virological data}
\usage{
fluview_clinical(regions, epiweeks, issues, lag)
}
\arguments{
\item{regions}{a \code{list} of \link{delphi_regions}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{issues}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{lag}{a number of weeks}
}
\description{
Fetch FluView virological data
}

16
man/gft.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{gft}
\alias{gft}
\title{Fetch Google Flu Trends data}
\usage{
gft(locations, epiweeks)
}
\arguments{
\item{locations}{a \code{list} of \link{delphi_regions}, \link{dephi_states}, and/or \link{delphi_cities}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch Google Flu Trends data
}

20
man/ght.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{ght}
\alias{ght}
\title{Fetch Google Health Trends data}
\usage{
ght(auth, locations, epiweeks, query)
}
\arguments{
\item{auth}{authentication token}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{delphi_cities}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{query}{google query}
}
\description{
Fetch Google Health Trends data
}

11
man/meta.Rd

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{meta}
\alias{meta}
\title{Fetch API metadata}
\usage{
meta()
}
\description{
Fetch API metadata
}

14
man/meta_norostat.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{meta_norostat}
\alias{meta_norostat}
\title{Fetch NoroSTAT metadata}
\usage{
meta_norostat(auth)
}
\arguments{
\item{auth}{auth token}
}
\description{
Fetch NoroSTAT metadata
}

16
man/nidss_dengue.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{nidss_dengue}
\alias{nidss_dengue}
\title{Fetch NIDSS dengue data}
\usage{
nidss_dengue(locations, epiweeks)
}
\arguments{
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch NIDSS dengue data
}

20
man/nidss_flu.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{nidss_flu}
\alias{nidss_flu}
\title{Fetch NIDSS flu data}
\usage{
nidss_flu(regions, epiweeks, issues, lag)
}
\arguments{
\item{regions}{a \code{list} of \link{delphi_regions}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{issues}{a \code{list} of issues}
\item{lag}{a number of weeks}
}
\description{
Fetch NIDSS flu data
}

18
man/norostat.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{norostat}
\alias{norostat}
\title{Fetch NoroSTAT data (point data, no min/max)}
\usage{
norostat(auth, location, epiweeks)
}
\arguments{
\item{auth}{auth token}
\item{location}{a single \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch NoroSTAT data (point data, no min/max)
}

16
man/nowcast.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{nowcast}
\alias{nowcast}
\title{Fetch Delphi's wILI nowcast}
\usage{
nowcast(locations, epiweeks)
}
\arguments{
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch Delphi's wILI nowcast
}

18
man/quidel.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{quidel}
\alias{quidel}
\title{Fetch Quidel data}
\usage{
quidel(auth, epiweeks, locations)
}
\arguments{
\item{auth}{auth token}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
}
\description{
Fetch Quidel data
}

20
man/sensors.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{sensors}
\alias{sensors}
\title{Fetch Delphi's digital surveillance sensors}
\usage{
sensors(auth, names, locations, epiweeks)
}
\arguments{
\item{auth}{auth token}
\item{names}{sensor name?}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{dephi_states}}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch Delphi's digital surveillance sensors
}

20
man/twitter.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{twitter}
\alias{twitter}
\title{Fetch HealthTweets data}
\usage{
twitter(auth, locations, dates, epiweeks)
}
\arguments{
\item{auth}{twitter auth token}
\item{locations}{a \code{list} of \link{delphi_regions} and/or \link{delphi_cities}}
\item{dates}{a \code{list} of dates (\code{YYYYMMDD} format)}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
}
\description{
Fetch HealthTweets data
}

20
man/wiki.Rd

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f.R
\name{wiki}
\alias{wiki}
\title{Fetch Wikipedia access data}
\usage{
wiki(articles, dates, epiweeks, hours)
}
\arguments{
\item{articles}{a \code{list} of \link{delphi_articles}}
\item{dates}{a \code{list} of dates (\code{YYYYMMDD} format)}
\item{epiweeks}{a \code{list} of epiweeks (format for an epiweek is \code{YYYYWW})}
\item{hours}{a \code{list} of hours}
}
\description{
Fetch Wikipedia access data
}
Loading…
Cancel
Save