Browse Source

fixing git

tags/v0.7.0
boB Rudis 6 years ago
parent
commit
99396a2bb3
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 12
      .Rbuildignore
  2. 1
      .codecov.yml
  3. 1
      .gitignore
  4. 5
      .travis.yml
  5. 25
      CONDUCT.md
  6. 32
      DESCRIPTION
  7. 37
      NAMESPACE
  8. 8
      NEWS.md
  9. 15
      R/aaa.R
  10. 16
      R/aaa.r
  11. 55
      R/agd-ipt.r
  12. 21
      R/cdcfluview-package.R
  13. 28
      R/coverage-map.r
  14. 38
      R/geographic-spread.R
  15. 102
      R/hospital.r
  16. 80
      R/ili-weekly-state.r
  17. 80
      R/ilinet.r
  18. 135
      R/pi-mortality.r
  19. 24
      R/utils.r
  20. 92
      R/who-nrvess.r
  21. 19
      R/zzz.r
  22. 189
      README.Rmd
  23. 216
      README.md
  24. 2
      cdcfluview.Rproj
  25. 22
      man/agd_ipt.Rd
  26. 32
      man/cdc_coverage_map.Rd
  27. 18
      man/cdcfluview.Rd
  28. 16
      man/geographic_spread.Rd
  29. 32
      man/hospitalizations.Rd
  30. 39
      man/ili_weekly_activity_indicators.Rd
  31. 40
      man/ilinet.Rd
  32. 54
      man/pi_mortality.Rd
  33. 14
      man/state_data_providers.Rd
  34. 14
      man/surveillance_areas.Rd
  35. 51
      man/who_nrevss.Rd
  36. 22
      tests/testthat/test-cdcfluview.R

12
.Rbuildignore

@ -1,6 +1,18 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^README\.*Rmd$
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$
^\.codecov\.yml$
^README_files$
^doc$
^CONDUCT\.md$
^codecov\.yml$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^.*md$
^crunch/
^crunch/.*

1
.codecov.yml

@ -0,0 +1 @@
comment: false

1
.gitignore

@ -1,3 +1,4 @@
.DS_Store
.Rproj.user
.Rhistory
.RData

5
.travis.yml

@ -12,6 +12,7 @@ r:
- release
- devel
<<<<<<< HEAD
notifications:
email:
- bob@rud.is
@ -22,3 +23,7 @@ notifications:
after_success:
- Rscript -e 'covr::codecov()'
=======
after_success:
- Rscript -e 'covr::codecov()'
>>>>>>> c0ce51942c79090d1a9ae3fb95f7e2b292d9302e

25
CONDUCT.md

@ -0,0 +1,25 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or
imagery, derogatory comments or personal attacks, trolling, public or private harassment,
insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the Contributor Covenant
(http:contributor-covenant.org), version 1.0.0, available at
http://contributor-covenant.org/version/1/0/0/

32
DESCRIPTION

@ -1,33 +1,37 @@
Package: cdcfluview
Type: Package
Title: Retrieve U.S. Flu Season Data from the CDC FluView Portal
Version: 0.6.0
Date: 2017-10-20
Authors@R: c(person("Bob","Rudis", email = "bob@rud.is", role = c("aut", "cre")),
person("Craig", "McGowan", email = "mcgowan.cj@gmail.com", role = "ctb"))
Encoding: UTF-8
Title: Retrieve 'U.S'.' Flu Season Data from the 'CDC' 'FluView' Portal
Version: 0.7.0
Date: 2017-11-04
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
person("Craig", "McGowan", email = "mcgowan.cj@gmail.com", role = "ctb")
)
Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is>
Description: The U.S. Centers for Disease Control (CDC) maintains a portal
<http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html> for
accessing state, regional and national influenza statistics as well as
Mortality Surveillance Data. The Flash interface makes it difficult and
time-consuming to select and retrieve influenza data. This package
provides functions to access the data provided by the portal's underlying API.
URL: http://github.com/hrbrmstr/cdcfluview
URL: https://github.com/hrbrmstr/cdcfluview
BugReports: https://github.com/hrbrmstr/cdcfluview/issues
License: MIT + file LICENSE
LazyData: true
Suggests:
testthat,
covr
Depends:
R (>= 3.2.0)
Imports:
httr (>= 0.3.0),
xml2,
httr,
tools,
dplyr,
utils,
purrr,
readr,
jsonlite,
V8
Depends:
R (>= 3.2.0)
stats,
utils,
sf
RoxygenNote: 6.0.1

37
NAMESPACE

@ -1,21 +1,24 @@
# Generated by roxygen2: do not edit by hand
export(get_flu_data)
export(get_hosp_data)
export(get_mortality_surveillance_data)
export(get_state_data)
export(get_weekly_flu_report)
import(V8)
import(dplyr)
export(agd_ipt)
export(cdc_coverage_map)
export(geographic_spread)
export(hospitalizations)
export(ili_weekly_activity_indicators)
export(ilinet)
export(pi_mortality)
export(state_data_providers)
export(surveillance_areas)
export(who_nrevss)
import(httr)
import(utils)
import(xml2)
importFrom(dplyr,"%>%")
importFrom(dplyr,bind_rows)
importFrom(dplyr,filter)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(jsonlite,fromJSON)
importFrom(purrr,discard)
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_df)
importFrom(purrr,map_lgl)
importFrom(readr,read_csv)
importFrom(readr,type_convert)
importFrom(sf,st_read)
importFrom(stats,setNames)
importFrom(tools,file_path_sans_ext)
importFrom(utils,read.csv)
importFrom(utils,unzip)

8
NEWS.md

@ -1,3 +1,8 @@
# cdcfluview 0.7.0
* The CDC changed most of their API endpoints to support a new HTML interface.
There are many breaking changes but also many new data endpoints.
# cdcfluview 0.5.2
* Modified behavior of `get_flu_data()` to actually grab current flu season
@ -18,3 +23,6 @@
better this will break your scripts until you use the new
column names.
# cdcfluview 0.4.0
* First CRAN release

15
R/aaa.R

@ -0,0 +1,15 @@
# CDC U.S. region names to ID map
.region_map <- c(national=3, hhs=1, census=2, state=5)
# CDC hospital surveillance surveillance area name to internal pkg use map
.surv_map <- c(`FluSurv-NET`="flusurv", `EIP`="eip", `IHSP`="ihsp")
.surv_rev_map <- c(flusurv="FluSurv-NET", eip="EIP", ihsp="IHSP")
# CDC P&I mortality GepID mapping
.geoid_map <- c(national="1", state="2", region="3")
# Our bot's user-agent string
.cdcfluview_ua <- "Mozilla/5.0 (compatible; R-cdcvluview Bot/2.0; https://github.com/hrbrmstr/cdcfluview)"
# CDC Basemap
.cdc_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView1References/data/US_States_w_PR_labels.json"

16
R/aaa.r

@ -1 +1,15 @@
utils::globalVariables(".")
# CDC U.S. region names to ID map
.region_map <- c(national=3, hhs=1, census=2, state=5)
# CDC hospital surveillance surveillance area name to internal pkg use map
.surv_map <- c(`FluSurv-NET`="flusurv", `EIP`="eip", `IHSP`="ihsp")
.surv_rev_map <- c(flusurv="FluSurv-NET", eip="EIP", ihsp="IHSP")
# CDC P&I mortality GepID mapping
.geoid_map <- c(national="1", state="2", region="3")
# Our bot's user-agent string
.cdcfluview_ua <- "Mozilla/5.0 (compatible; R-cdcvluview Bot/2.0; https://github.com/hrbrmstr/cdcfluview)"
# CDC Basemap
.cdc_basemap <- "https://gis.cdc.gov/grasp/fluview/FluView1References/data/US_States_w_PR_labels.json"

55
R/agd-ipt.r

@ -0,0 +1,55 @@
#' Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
#'
#' Retrieves the age group distribution of influenza positive tests that are reported by
#' public health laboratories by influenza virus type and subtype/lineage. Laboratory data
#' from multiple seasons and different age groups is provided.
#'
#' @references
#' - [CDC FluView Portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html)
#' - [AGD IPT Portal](https://gis.cdc.gov/grasp/fluview/flu_by_age_virus.html)
#' @export
#' @examples \dontrun{
#' agd_ipt()
#' }
agd_ipt <- function() {
httr::GET(
url = "https://gis.cdc.gov/grasp/fluView6/GetFlu6AllDataP",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/flu_by_age_virus.html"
),
httr::verbose(),
httr::timeout(60)
) -> res
httr::stop_for_status(res)
xdat <- httr::content(res, as="parsed")
xdat <- jsonlite::fromJSON(xdat, flatten=TRUE)
sea_names <- c("seasonid", "sea_description", "sea_startweek", "sea_endweek", "sea_enabled",
"sea_label", "sea_showlabtype")
age_names <- c("ageid", "age_label", "age_color_hexvalue", "age_enabled")
typ_names <- c("virusid", "vir_description", "vir_label", "vir_startmmwrid", "vir_endmmwrid",
"vir_displayorder", "vir_colorname", "vir_color_hexvalue", "vir_labtypeid",
"vir_sortid")
vir_names <- c("virusid", "ageid", "count", "mmwrid", "seasonid", "publishyearweekid", "loaddatetime")
sea_df <- stats::setNames(xdat$Season, sea_names)
age_df <- stats::setNames(xdat$Age, age_names)
typ_df <- stats::setNames(xdat$VirusType, typ_names)
vir_df <- stats::setNames(xdat$VirusData, vir_names)
vir_df <- dplyr::left_join(vir_df, sea_df, "seasonid")
vir_df <- dplyr::left_join(vir_df, age_df, "ageid")
vir_df <- dplyr::left_join(vir_df, typ_df, "virusid")
class(vir_df) <- c("tbl_df", "tbl", "data.frame")
vir_df_cols <- c("sea_label", "age_label", "vir_label", "count", "mmwrid", "seasonid",
"publishyearweekid", "sea_description", "sea_startweek", "sea_endweek",
"vir_description", "vir_startmmwrid", "vir_endmmwrid")
vir_df[,vir_df_cols]
}

21
R/cdcfluview-package.R

@ -1,17 +1,22 @@
#' Retrieve Flu Season Data from the CDC FluView Portal
=======
#' Retrieve 'U.S'.' Flu Season Data from the 'CDC' 'FluView' Portal
#'
#' The U.S. Centers for Disease Control (CDC) maintains a portal
#' \code{https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html} for
#' <http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html> for
#' accessing state, regional and national influenza statistics as well as
#' Mortality Surveillance Data. The Flash interface makes it difficult
#' and time-consuming to select and retrieve influenza data. This package
#' provides functions to access the data provided by portal's underlying API.
#' Mortality Surveillance Data. The Flash interface makes it difficult and
#' time-consuming to select and retrieve influenza data. This package
#' provides functions to access the data provided by the portal's underlying API.
#'
#' @md
#' @name cdcfluview
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import httr xml2 dplyr utils V8
#' @importFrom purrr map map_df map_chr map_lgl discard keep
#' @importFrom readr read_csv type_convert
#' @import httr
#' @importFrom tools file_path_sans_ext
#' @importFrom dplyr left_join bind_rows mutate filter %>%
#' @importFrom jsonlite fromJSON
#' @importFrom stats setNames
#' @importFrom sf st_read
#' @importFrom utils read.csv unzip
NULL

28
R/coverage-map.r

@ -0,0 +1,28 @@
#' Retrieve CDC U.S. Coverage Map
#'
#' The CDC FluView application uses a composite basemap of coverage areas
#' within the United States that elides and scales Alaska, Hawaii and
#' Puerto Rico and provides elided and scaled breakouts for New York City
#' and the District of Columbia.\cr
#' \cr
#' The basemap provides polygon identifiers by:
#' \cr
#' - `STATE_FIPS`
#' - `STATE_ABBR`
#' - `STATE_NAME`
#' - `HHS_Region`
#' - `FIPSTXT`)
#' \cr
#' This function retrieves the shapefile, projects to EPSG:5069 and
#' returns it as an `sf` (simple features) object.
#'
#' @md
#' @export
#' @examples \dontrun{
#' plot(cdc_coverage_map())
#' }
cdc_coverage_map <- function() {
xsf <- sf::st_read(.cdc_basemap, quiet=TRUE, stringsAsFactors=FALSE)
sf::st_crs(xsf) <- 4326
sf::st_transform(xsf, 5069)
}

38
R/geographic-spread.R

@ -0,0 +1,38 @@
#' State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
#'
#' @export
#' @examples \dontrun{
#' geographic_spread()
#' }
geographic_spread <- function() {
meta <- jsonlite::fromJSON("https://gis.cdc.gov/grasp/Flu8/GetPhase08InitApp?appVersion=Public")
meta$seasons$seasonid
httr::POST(
url = "https://gis.cdc.gov/grasp/Flu8/PostPhase08DownloadData",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Origin = "https://gis.cdc.gov",
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/FluView8.html"
),
encode = "json",
body = list(
AppVersion = "Public",
SeasonIDs = paste0(meta$seasons$seasonid, collapse=",")
),
httr::timeout(60),
httr::verbose()
) -> res
httr::stop_for_status(res)
res <- httr::content(res, as="parsed", flatten=TRUE)
xdf <- dplyr::bind_rows(res$datadownload)
xdf$weekend <- as.Date(xdf$weekend, format="%B-%d-%Y")
xdf
}

102
R/hospital.r

@ -0,0 +1,102 @@
#' Laboratory-Confirmed Influenza Hospitalizations
#'
#' @md
#' @param surveillance_area one of "`flusurv`", "`eip`", or "`ihsp`"
#' @param region Using "`all`" mimics selecting "Entire Network" from the
#' CDC FluView application drop down. Individual regions for each
#' surveillance area can also be selected. Use [surveillance_areas()] to
#' see a list of valid sub-regions for each surveillance area.
#' @references
#' - [Hospital Portal](https://gis.cdc.gov/GRASP/Fluview/FluHospRates.html)
#' @export
#' @examples \dontrun{
#' hosp_fs <- hospitalizations("flusurv")
#' hosp_eip <- hospitalizations("eip")
#' hosp_ihsp <- hospitalizations("ihsp")
#' }
hospitalizations <- function(surveillance_area=c("flusurv", "eip", "ihsp"),
region="all") {
sarea <- match.arg(tolower(surveillance_area), choices = c("flusurv", "eip", "ihsp"))
sarea <- .surv_rev_map[sarea]
meta <- jsonlite::fromJSON("https://gis.cdc.gov/GRASP/Flu3/GetPhase03InitApp?appVersion=Public")
areas <- setNames(meta$catchments[,c("networkid", "name", "area", "catchmentid")],
c("networkid", "surveillance_area", "region", "id"))
reg <- region
if (reg == "all") reg <- "Entire Network"
tgt <- dplyr::filter(areas, (surveillance_area == sarea) & (region == reg))
if (nrow(tgt) == 0) {
stop("Region not found. Use `surveillance_areas()` to see a list of valid inputs.",
call.=FALSE)
}
httr::POST(
url = "https://gis.cdc.gov/GRASP/Flu3/PostPhase03GetData",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Origin = "https://gis.cdc.gov",
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html"
),
encode = "json",
body = list(
appversion = "Public",
networkid = tgt$networkid,
cacthmentid = tgt$id
),
httr::verbose()
) -> res
httr::stop_for_status(res)
res <- httr::content(res)
hosp <- list(res = res, meta = meta)
age_df <- setNames(hosp$meta$ages, c("age_label", "age", "color"))
age_df <- age_df[,c("age", "age_label")]
sea_df <- setNames(
hosp$meta$seasons,
c("sea_description", "sea_endweek", "sea_label", "seasonid", "sea_startweek", "color", "color_hexvalue"))
sea_df <- sea_df[,c("seasonid", "sea_label", "sea_description", "sea_startweek", "sea_endweek")]
ser_names <- unlist(hosp$res$busdata$datafields, use.names = FALSE)
mmwr_df <- bind_rows(hosp$res$mmwr)
mmwr_df <- mmwr_df[,c("mmwrid", "weekend", "weeknumber", "weekstart", "year",
"yearweek", "seasonid", "weekendlabel", "weekendlabel2")]
dplyr::bind_rows(lapply(hosp$res$busdata$dataseries, function(.x) {
tdf <- dplyr::bind_rows(lapply(.x$data, function(.x) setNames(.x, ser_names)))
tdf$age <- .x$age
tdf$season <- .x$season
tdf
})) -> xdf
dplyr::left_join(xdf, mmwr_df, c("mmwrid", "weeknumber")) %>%
dplyr::left_join(age_df, "age") %>%
dplyr::left_join(sea_df, "seasonid") %>%
dplyr::mutate(
surveillance_area = sarea,
region = reg
)
}
#' Retrieve a list of valid sub-regions for each surveillance area.
#'
#' @md
#' @export
#' @examples
#' surveillance_areas()
surveillance_areas <- function() {
meta <- jsonlite::fromJSON("https://gis.cdc.gov/GRASP/Flu3/GetPhase03InitApp?appVersion=Public")
xdf <- setNames(meta$catchments[,c("name", "area")], c("surveillance_area", "region"))
xdf$surveillance_area <- .surv_map[xdf$surveillance_area]
xdf
}

80
R/ili-weekly-state.r

@ -0,0 +1,80 @@
#' Retrieve weekly state-level ILI indicators per-state for a given season
#'
#' @md
#' @param season_start_year numeric; start year for flu season (e.g. 2017 for 2017-2018 season)
#' @references
#' - [ILI Activity Indicator Map Portal](https://gis.cdc.gov/grasp/fluview/main.html)
#' @note These statistics use the proportion of outpatient visits to healthcare providers
#' for influenza-like illness to measure the ILI activity level within a state. They do
#' not, however, measure the extent of geographic spread of flu within a state. Therefore,
#' outbreaks occurring in a single city could cause the state to display high activity levels.\cr
#' \cr
#' Data collected in ILINet may disproportionately represent certain populations within
#' a state, and therefore may not accurately depict the full picture of influenza activity
#' for the whole state.\cr
#' \cr
#' All summary statistics are based on either data collected in ILINet, or reports from
#' state and territorial epidemiologists. Differences in the summary data presented by
#' CDC and state health departments likely represent differing levels of data completeness
#' with data presented by the state likely being the more complete.
#' @export
#' @examples \dontrun{
#' ili_weekly_activity_indicators(2016)
#' }
ili_weekly_activity_indicators <- function(season_start_year) {
jsonlite::fromJSON("https://gis.cdc.gov/grasp/fluView1/Phase1IniP") %>%
jsonlite::fromJSON() -> meta
season <- season_start_year - 1960
res <- httr::GET(sprintf("https://gis.cdc.gov/grasp/fluView1/Phase1SeasonDataP/%s",
season))
httr::stop_for_status(res)
res <- httr::content(res, as="parsed")
res <- jsonlite::fromJSON(res)
setNames(
meta$ili_intensity[,c("iliActivityid", "ili_activity_label", "legend")],
c("iliactivityid", "ili_activity_label", "ili_activity_group")
) -> iliact
dplyr::left_join(res$busdata, meta$stateinfo, "stateid") %>%
dplyr::left_join(res$mmwr, "mmwrid") %>%
dplyr::left_join(iliact, "iliactivityid") -> xdf
xdf <- xdf[,c("statename", "ili_activity_label", "ili_activity_group",
"statefips", "stateabbr", "weekend", "weeknumber", "year", "seasonid")]
xdf$statefips <- trimws(xdf$statefips)
xdf$stateabbr <- trimws(xdf$stateabbr)
xdf$weekend <- as.Date(xdf$weekend)
xdf$ili_activity_label <- factor(xdf$ili_activity_label,
levels=iliact$ili_activity_label)
class(xdf) <- c("tbl_df", "tbl", "data.frame")
xdf
}
#' Retrieve metadat about U.S. State CDC Provider Data
#'
#' @md
#' @export
#' @examples
#' state_data_providers()
state_data_providers <- function() {
jsonlite::fromJSON("https://gis.cdc.gov/grasp/fluView1/Phase1IniP") %>%
jsonlite::fromJSON() -> meta
state_info <- meta$stateinfo
state_info <- state_info[,c("statename", "statehealthdeptname", "url", "statewebsitename", "statefluphonenum")]
class(state_info) <- c("tbl_df", "tbl", "data.frame")
state_info
}

80
R/ilinet.r

@ -0,0 +1,80 @@
#' Retrieve ILINet Surveillance Data
#'
#' The CDC FluView Portal provides in-season and past seasons' national, regional,
#' and state-level outpatient illness and viral surveillance data from both
#' ILINet (Influenza-like Illness Surveillance Network) and WHO/NREVSS
#' (National Respiratory and Enteric Virus Surveillance System).
#'
#' This function retrieves current and historical ILINet surveillance data for
#' the identified region.
#'
#' @md
#' @param region one of "`national`", "`hhs`", "`census`", or "`state`"
#' @references
#' - [CDC FluView Portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html)
#' - [ILINet Portal](https://wwwn.cdc.gov/ilinet/) (Login required)
#' - [WHO/NREVSS](https://www.cdc.gov/surveillance/nrevss/index.html)
#' @export
#' @examples
#' national_ili <- ilinet("national")
#' hhs_ili <- ilinet("hhs")
#' census_ili <- ilinet("census")
#' state_ili <- ilinet("state")
#' \dontrun{
#' library(purrr)
#' map_df(
#' c("national", "hhs", "census", "state"),
#' ~ilinet(.x) %>% readr::type_convert())
#' }
ilinet <- function(region=c("national", "hhs", "census", "state")) {
region <- match.arg(tolower(region), c("national", "hhs", "census", "state"))
list(
AppVersion = "Public",
DatasourceDT = list(list(ID = 1, Name = "ILINet")),
RegionTypeId = .region_map[region]
) -> params
params$SubRegionsDT <- switch(region,
national = { list(list(ID=0, Name="")) },
hhs = { lapply(1:10, function(i) list(ID=i, Name=as.character(i))) },
census = { lapply(1:9, function(i) list(ID=i, Name=as.character(i))) },
state = { lapply(1:59, function(i) list(ID=i, Name=as.character(i))) }
)
seasons <- 37:((unclass(as.POSIXlt(Sys.time()))[["year"]] + 1900) - 1960)
params$SeasonsDT <- lapply(seasons, function(i) list(ID=i, Name=as.character(i)))
tf <- tempfile(fileext = ".zip")
td <- tempdir()
on.exit(unlink(tf), TRUE)
httr::POST(
url = "https://gis.cdc.gov/grasp/flu2/PostPhase02DataDownload",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Origin = "https://gis.cdc.gov",
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html"
),
encode = "json",
body = params,
httr::verbose(),
httr::write_disk(tf)
) -> res
httr::stop_for_status(res)
nm <- unzip(tf, overwrite = TRUE, exdir = td)
xdf <- read.csv(nm, skip = 1, stringsAsFactors=FALSE)
xdf <- .mcga(xdf)
class(xdf) <- c("tbl_df", "tbl", "data.frame")
xdf[xdf=="X"] <- NA
xdf
}

135
R/pi-mortality.r

@ -0,0 +1,135 @@
#' Pneumonia and Influenza Mortality Surveillance
#'
#' The National Center for Health Statistics (NCHS) collects and disseminates the Nation's
#' official vital statistics. NCHS collects death certificate data from state vital
#' statistics offices for virtually all deaths occurring in the United States. Pneumonia
#' and influenza (P&I) deaths are identified based on ICD-10
#' multiple cause of death codes.\cr
#' \cr
#' NCHS Mortality Surveillance System data are presented by the week the death occurred
#' at the national, state, and HHS Region levels. Data on the percentage of deaths due
#' to P&I on a national level are released two weeks after the week of death to allow
#' for collection of enough data to produce a stable percentage. States and HHS regions
#' with less than 20% of the expected total deaths (average number of total deaths
#' reported by week during 2008-2012) will be marked as insufficient data. Collection
#' of complete data is not expected at the time of initial report, and a reliable
#' percentage of deaths due to P&I is not anticipated at the U.S. Department of Health
#' and Human Services region or state level within this two week period. The data for
#' earlier weeks are continually revised and the proportion of deaths due to P&I may
#' increase or decrease as new and updated death certificate data are received by NCHS.\cr
#' \cr
#' The seasonal baseline of P&I deaths is calculated using a periodic regression model
#' that incorporates a robust regression procedure applied to data from the previous
#' five years. An increase of 1.645 standard deviations above the seasonal baseline
#' of P&I deaths is considered the "epidemic threshold," i.e., the point at which
#' the observed proportion of deaths attributed to pneumonia or influenza was
#' significantly higher than would be expected at that time of the year in the
#' absence of substantial influenza-related mortality. Baselines and thresholds are
#' calculated at the national and regional level and by age group.
#'
#' @md
#' @param coverage_area coverage area for data (national, state or region)
#' @note Queries for "state" and "region" are not "instantaneous" and can near or over 30s retrieval delays.
#' @references
#' - [Pneumonia and Influenza Mortality Surveillance Portal](https://gis.cdc.gov/grasp/fluview/mortality.html)
#' @export
#' @examples \dontrun{
#' ndf <- pi_mortality()
#' sdf <- pi_mortality("state")
#' rdf <- pi_mortality("region")
#' }
pi_mortality <- function(coverage_area=c("national", "state", "region")) {
coverage_area <- match.arg(tolower(coverage_area), choices = c("national", "state", "region"))
us_states <- read.csv("https://gis.cdc.gov/grasp/fluview/Flu7References/Data/USStates.csv",
stringsAsFactors=FALSE)
us_states <- setNames(us_states, c("region_name", "subgeoid", "state_abbr"))
us_states <- us_states[,c("region_name", "subgeoid")]
us_states$subgeoid <- as.character(us_states$subgeoid)
meta <- jsonlite::fromJSON("https://gis.cdc.gov/grasp/flu7/GetPhase07InitApp?appVersion=Public")
mapcode_df <- setNames(meta$nchs_mapcode[,c("mapcode", "description")], c("map_code", "callout"))
mapcode_df$map_code <- as.character(mapcode_df$map_code)
geo_df <- meta$nchs_geo_dim
geo_df$geoid <- as.character(geo_df$geoid)
age_df <- setNames(meta$nchs_ages, c("ageid", "age_label"))
age_df$ageid <- as.character(age_df$ageid)
mwmr_df <- meta$mmwr
mwmr_df$mmwrid <- as.character(mwmr_df$mmwrid)
mwmr_df <- setNames(mwmr_df,
c("mmwrid", "weekend", "mwmr_weeknumber", "weekstart",
"year", "yearweek", "mwmr_seasonid", "mwmr_label", "weekendlabel"))
sum_df <- meta$nchs_summary
sum_df$seasonid <- as.character(sum_df$seasonid)
sum_df$ageid <- as.character(sum_df$ageid)
sum_df$geoid <- as.character(sum_df$geoid)
httr::POST(
url = "https://gis.cdc.gov/grasp/flu7/PostPhase07DownloadData",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Origin = "https://gis.cdc.gov",
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/mortality.html"
),
encode = "json",
body = list(
AppVersion = "Public",
AreaParameters = list(list(ID=.geoid_map[coverage_area])),
SeasonsParameters = lapply(meta$seasons$seasonid, function(.x) { list(ID=as.integer(.x)) }),
AgegroupsParameters = list(list(ID="1"))
),
httr::timeout(60),
httr::verbose()
) -> res
httr::stop_for_status(res)
res <- httr::content(res, as="parsed", flatten=TRUE)
dplyr::bind_rows(res$seasons) %>%
dplyr::left_join(mapcode_df, "map_code") %>%
dplyr::left_join(geo_df, "geoid") %>%
dplyr::left_join(age_df, "ageid") %>%
dplyr::left_join(mwmr_df, "mmwrid") -> xdf
xdf <- dplyr::mutate(xdf, coverage_area = coverage_area)
if (coverage_area == "state") {
xdf <- dplyr::left_join(xdf, us_states, "subgeoid")
} else if (coverage_area == "region") {
xdf$region_name <- sprintf("Region %s", xdf$subgeoid)
} else {
xdf$region_name <- NA_character_
}
xdf[,c("seasonid", "baseline", "threshold", "percent_pni",
"percent_complete", "number_influenza", "number_pneumonia",
"all_deaths", "Total_PnI", "weeknumber", "geo_description",
"age_label", "weekend", "weekstart", "year", "yearweek",
"coverage_area", "region_name", "callout")] -> xdf
suppressWarnings(xdf$baseline <- to_num(xdf$baseline))
suppressWarnings(xdf$threshold <- to_num(xdf$threshold))
suppressWarnings(xdf$percent_pni <- to_num(xdf$percent_pni) / 100)
suppressWarnings(xdf$percent_complete <- to_num(xdf$percent_complete) / 100)
suppressWarnings(xdf$number_influenza <- to_num(xdf$number_influenza))
suppressWarnings(xdf$number_pneumonia <- to_num(xdf$number_pneumonia))
suppressWarnings(xdf$all_deaths <- to_num(xdf$all_deaths))
suppressWarnings(xdf$Total_PnI <- to_num(xdf$Total_PnI))
suppressWarnings(xdf$weekend <- as.Date(xdf$weekend))
suppressWarnings(xdf$weekstart <- as.Date(xdf$weekstart))
xdf <- .mcga(xdf)
xdf
}

24
R/utils.r

@ -0,0 +1,24 @@
.mcga <- function(tbl) {
x <- colnames(tbl)
x <- tolower(x)
x <- gsub("[[:punct:][:space:]]+", "_", x)
x <- gsub("_+", "_", x)
x <- gsub("(^_|_$)", "", x)
x <- gsub("^x_", "", x)
x <- make.unique(x, sep = "_")
colnames(tbl) <- x
tbl
}
to_num <- function(x) {
x <- gsub("%", "", x, fixed=TRUE)
x <- gsub(">", "", x, fixed=TRUE)
x <- gsub("<", "", x, fixed=TRUE)
x <- gsub(",", "", x, fixed=TRUE)
x <- gsub(" ", "", x, fixed=TRUE)
as.numeric(x)
}

92
R/who-nrvess.r

@ -0,0 +1,92 @@
#' Retrieve WHO/NREVSS Surveillance Data
#'
#' The CDC FluView Portal provides in-season and past seasons' national, regional,
#' and state-level outpatient illness and viral surveillance data from both
#' ILINet (Influenza-like Illness Surveillance Network) and WHO/NREVSS
#' (National Respiratory and Enteric Virus Surveillance System).
#'
#' This function retrieves current and historical WHO/NREVSS surveillance data for
#' the identified region.
#'
#' @md
#' @note HHS, Census and State data retrieval is not as "instantaneous" as their ILINet
#' counterparts.\cr\cr
#' Also, beginning for the 2015-16 season, reports from public health and clinical
#' laboratories are presented separately in the weekly influenza update. This is
#' the reason why a list of data frames is returned.
#' @param region one of "`national`", "`hhs`", "`census`", or "`state`"
#' @return list of data frames identified by
#' - `combined_prior_to_2015_16`
#' - `public_health_labs`
#' - `clinical_labs`
#' @references
#' - [CDC FluView Portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html)
#' - [ILINet Portal](https://wwwn.cdc.gov/ilinet/) (Login required)
#' - [WHO/NREVSS](https://www.cdc.gov/surveillance/nrevss/index.html)
#' @export
#' @examples \dontrun{
#' national_who <- who_nrevss("national")
#' hhs_who <- who_nrevss("hhs")
#' census_who <- who_nrevss("census")
#' state_who <- who_nrevss("state")
#' }
who_nrevss <- function(region=c("national", "hhs", "census", "state")) {
region <- match.arg(tolower(region), c("national", "hhs", "census", "state"))
list(
AppVersion = "Public",
DatasourceDT = list(list(ID = 1, Name = "WHO_NREVSS")),
RegionTypeId = .region_map[region]
) -> params
params$SubRegionsDT <- switch(
region,
national = { list(list(ID=0, Name="")) },
hhs = { lapply(1:10, function(i) list(ID=i, Name=as.character(i))) },
census = { lapply(1:9, function(i) list(ID=i, Name=as.character(i))) },
state = { lapply(1:59, function(i) list(ID=i, Name=as.character(i))) }
)
seasons <- 37:((unclass(as.POSIXlt(Sys.time()))[["year"]] + 1900) - 1960)
params$SeasonsDT <- lapply(seasons, function(i) list(ID=i, Name=as.character(i)))
tf <- tempfile(fileext = ".zip")
td <- tempdir()
on.exit(unlink(tf), TRUE)
httr::POST(
url = "https://gis.cdc.gov/grasp/flu2/PostPhase02DataDownload",
httr::user_agent(.cdcfluview_ua),
httr::add_headers(
Origin = "https://gis.cdc.gov",
Accept = "application/json, text/plain, */*",
Referer = "https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html"
),
encode = "json",
body = params,
httr::verbose(),
httr::timeout(60),
httr::write_disk(tf)
) -> res
httr::stop_for_status(res)
nm <- unzip(tf, overwrite = TRUE, exdir = td)
lapply(nm, function(x) {
tdf <- read.csv(x, skip = 1, stringsAsFactors=FALSE)
tdf <- .mcga(tdf)
class(tdf) <- c("tbl_df", "tbl", "data.frame")
tdf[tdf=="X"] <- NA
tdf
}) -> xdf
setNames(xdf, sub("who_nrevss_", "", tools::file_path_sans_ext(tolower(basename(nm)))))
}

19
R/zzz.r

@ -1,12 +1,11 @@
# this is only used during active development phases before/after CRAN releases
# .onAttach <- function(...) {
#
# if (!interactive()) return()
#
# packageStartupMessage(paste0("cdcfluview is under *active* development. ",
# "There are *breaking changes*. ",
# "See https://github.com/hrbrmstr/cdcfluview for info/news."))
#
# }
#
.onAttach <- function(...) {
if (!interactive()) return()
packageStartupMessage(paste0("cdcfluview is under *active* development. ",
"There are *MASSIVE* breaking changes*. ",
"See https://github.com/hrbrmstr/cdcfluview for info/news."))
}

189
README.Rmd

@ -1,190 +1,71 @@
---
title: ""
pagetitle: ""
output: rmarkdown::github_document
---
```{r, echo=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
warning = FALSE,
message = FALSE,
comment = "#>",
fig.path = "README_files/README-",
fig.retina = 2
)
```
### :mask: cdcfluview - Retrieve U.S. Flu Season Data from the CDC FluView Portal
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/cdcfluview)](https://cran.r-project.org/package=cdcfluview)
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/cdcfluview.svg?branch=master)](https://travis-ci.org/hrbrmstr/cdcfluview)
[![Coverage Status](https://img.shields.io/codecov/c/github/hrbrmstr/cdcfluview/master.svg)](https://codecov.io/github/hrbrmstr/cdcfluview?branch=master)
**NOTE** If there's a particular data set from https://www.cdc.gov/flu/weekly/fluviewinteractive.htm that you want and that isn't in the package, please file it as an issue and be as specific as you can (screen shot if possible).
# I M P O R T A N T
The CDC migrated to a new non-Flash portal and back-end APIs changed. This is a complete reimagining of the package and --- as such --- all your code is going to break. Please use GitHub issues to identify previous API functionality you would like ported over. There's a [release candidate for 0.5.2](https://github.com/hrbrmstr/cdcfluview/releases/tag/v0.5.2) which uses the old API but it likely to break in the near future given the changes to the hidden API. You can do what with `devtools::install_github("hrbrmstr/cdcfluview", ref="58c172b")`.
All folks providing feedback, code or suggestions will be added to the DESCRIPTION file. Please include how you would prefer to be cited in any issues you file.
If there's a particular data set from https://www.cdc.gov/flu/weekly/fluviewinteractive.htm that you want and that isn't in the package, please file it as an issue and be as specific as you can (screen shot if possible).
# :mask: cdcfluview
-----
Retrieve U.S. Flu Season Data from the CDC FluView Portal
The U.S. Centers for Disease Control (CDC) maintains a [portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html) for accessing state, regional and national influenza statistics. The portal's Flash interface makes it difficult and time-consuming to select and retrieve influenza data. This package provides functions to access the data provided by the portal's underlying API.
## Description
The U.S. Centers for Disease Control (CDC) maintains a portal <http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html> for accessing state, regional and national influenza statistics as well as Mortality Surveillance Data. The Flash interface makes it difficult and time-consuming to select and retrieve influenza data. This package provides functions to access the data provided by the portal's underlying API.
## What's Inside The Tin
The following functions are implemented:
- `get_flu_data`: Retrieves state, regional or national influenza statistics from the CDC
- `get_state_data`: Retrieves state/territory-level influenza statistics from the CDC
- `get_weekly_flu_report`: Retrieves (high-level) weekly influenza surveillance report from the CDC
- `get_mortality_surveillance_data` : (fairly self explanatory but also pretty new to the pkg and uses data from: https://www.cdc.gov/flu/weekly/nchs.htm
- `agd_ipt`: Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
- `cdcfluview`: Tools to Work with the 'CDC' 'FluView' 'API'
- `cdc_coverage_map`: Retrieve CDC U.S. Coverage Map
- `geographic_spread`: State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
- `hospitalizations`: Laboratory-Confirmed Influenza Hospitalizations
- `ilinet`: Retrieve ILINet Surveillance Data
- `ili_weekly_activity_indicators`: Retrieve weekly state-level ILI indicators per-state for a given season
- `pi_mortality`: Pneumonia and Influenza Mortality Surveillance
- `state_data_providers`: Retrieve metadat about U.S. State CDC Provider Data
- `surveillance_areas`: Retrieve a list of valid sub-regions for each surveillance area.
- `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data
The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables)
- `census_regions` Census Region Table (a data frame with 51 rows and 2 variables)
### News
- See NEWS
- Version 0.4.0 - [CRAN release](http://cran.r-project.org/web/packages/cdcfluview)
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data files for HHS/Census region lookups; added weekly high-level flu report retrieval
- Version 0.3 released : fix for the CDC API (it changed how year & region params are encoded in the request)
- Version 0.2.1 released : bumped up `httr` version # requirement in `DESCRIPTION` (via Issue [1](https://github.com/hrbrmstr/cdcfluview/issues/1))
- Version 0.2 released : added state-level data retrieval
- Version 0.1 released
### Installation
## Installation
```{r eval=FALSE}
install.packages("cdcfluview")
# **OR**
devtools::install_github("hrbrmstr/cdcfluview")
```
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```
### Usage
## Usage
```{r state2015, message=FALSE, warning=FALSE, fig.height=10, fig.width=6}
```{r message=FALSE, warning=FALSE, error=FALSE}
library(cdcfluview)
library(ggplot2)
library(dplyr)
library(statebins)
# current verison
packageVersion("cdcfluview")
flu <- get_flu_data("hhs", sub_region=1:10, "ilinet", years=2014)
glimpse(flu)
state_flu <- get_state_data(years=2015)
glimpse(state_flu)
gg <- ggplot(flu, aes(x=WEEK, y=`% WEIGHTED ILI`, group=REGION))
gg <- gg + geom_line()
gg <- gg + facet_wrap(~REGION, ncol=2)
gg <- gg + theme_bw()
gg
```
```{r mortality, message=FALSE, warning=FALSE, fig.height=6, fig.width=10}
msd <- get_mortality_surveillance_data()
mutate(msd$by_state, ym=as.Date(sprintf("%04d-%02d-1", Year, Week), "%Y-%U-%u")) %>%
select(state, wk=ym, death_pct=`Percent of Deaths Due to Pneumonia and Influenza`) %>%
mutate(death_pct=death_pct/100) -> df
gg <- ggplot() + geom_smooth(data=df, aes(wk, death_pct, group=state),
se=FALSE, color="#2b2b2b", size=0.25)
gb <- ggplot_build(gg)
gb$data[[1]] %>%
arrange(desc(x)) %>%
group_by(group) %>%
slice(1) %>%
ungroup() %>%
arrange(desc(y)) %>%
head(1) -> top
top_state <- sort(unique(msd$by_state$state))[top$group]
gg <- gg + geom_text(data=top, aes(as.Date(x, origin="1970-01-01"), y, label=top_state),
hjust=1, family="Arial Narrow", size=3, nudge_x=-5, nudge_y=-0.001)
gg <- gg + scale_x_date(expand=c(0,0))
gg <- gg + scale_y_continuous(label=scales::percent)
gg <- gg + labs(x=NULL, y=NULL,
title="Percent of In-State Deaths Due to Pneumonia and Pnfluenza (2010-Present)")
gg <- gg + theme_bw(base_family="Arial Narrow")
gg <- gg + theme(axis.text.x=element_text(margin=margin(0,0,0,0)))
gg <- gg + theme(axis.text.y=element_text(margin=margin(0,0,0,0)))
gg <- gg + theme(axis.ticks=element_blank())
gg <- gg + theme(plot.title=element_text(face="bold", size=16))
gg
```
```{r region, eval=FALSE, include=FALSE, warning=FALSE, error=FALSE, message=FALSE}
dat <- get_flu_data(region="hhs",
sub_region=1:10,
data_source="ilinet",
years=2000:2014)
dat %>%
mutate(REGION=factor(REGION,
levels=unique(REGION),
labels=c("Boston", "New York",
"Philadelphia", "Atlanta",
"Chicago", "Dallas",
"Kansas City", "Denver",
"San Francisco", "Seattle"),
ordered=TRUE)) %>%
mutate(season_week=ifelse(WEEK>=40, WEEK-40, WEEK),
season=ifelse(WEEK<40,
sprintf("%d-%d", YEAR-1, YEAR),
sprintf("%d-%d", YEAR, YEAR+1))) -> dat
prev_years <- dat %>% filter(season != "2014-2015")
curr_year <- dat %>% filter(season == "2014-2015")
curr_week <- tail(dat, 1)$season_week
gg <- ggplot()
gg <- gg + geom_point(data=prev_years,
aes(x=season_week, y=`% WEIGHTED ILI`, group=season),
color="#969696", size=1, alpha=0.25)
gg <- gg + geom_point(data=curr_year,
aes(x=season_week, y=`% WEIGHTED ILI`, group=season),
color="red", size=1.25, alpha=1)
gg <- gg + geom_line(data=curr_year,
aes(x=season_week, y=`% WEIGHTED ILI`, group=season),
size=1.25, color="#d7301f")
gg <- gg + geom_vline(xintercept=curr_week, color="#d7301f", size=0.5, linetype="dashed", alpha=0.5)
gg <- gg + facet_wrap(~REGION, ncol=3)
gg <- gg + labs(x=NULL, y="Weighted ILI Index",
title="ILINet - 1999-2015 year weighted flu index history by CDC region\nWeek Ending Jan 3, 2015 (Red == 2014-2015 season)\n")
gg <- gg + theme_bw()
gg <- gg + theme(panel.grid=element_blank())
gg <- gg + theme(strip.background=element_blank())
gg <- gg + theme(axis.ticks.x=element_blank())
gg <- gg + theme(axis.text.x=element_blank())
```
```{r bins, message=FALSE, fig.height=5, fig.width=7}
gg_s <- state_flu %>%
filter(weekend=="Jan-02-2016") %>%
select(state=statename, value=activity_level) %>%
filter(!(state %in% c("Puerto Rico", "New York City"))) %>% # need to add PR to statebins
mutate(value=as.numeric(gsub("Level ", "", value))) %>%
statebins(brewer_pal="RdPu", breaks=4,
labels=c("Minimal", "Low", "Moderate", "High"),
legend_position="bottom", legend_title="ILI Activity Level") +
ggtitle("CDC State FluView (2015-01-03)")
gg_s
```
### EXAMPLES COMING SOON
### Test Results
```{r message=FALSE}
library(cdcfluview)
library(testthat)
date()
test_dir("tests/")
```
## 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.

216
README.md

@ -1,163 +1,101 @@
### :mask: cdcfluview - Retrieve U.S. Flu Season Data from the CDC FluView Portal
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/cdcfluview)](https://cran.r-project.org/package=cdcfluview) [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/cdcfluview.svg?branch=master)](https://travis-ci.org/hrbrmstr/cdcfluview) [![Coverage Status](https://img.shields.io/codecov/c/github/hrbrmstr/cdcfluview/master.svg)](https://codecov.io/github/hrbrmstr/cdcfluview?branch=master)
**NOTE** If there's a particular data set from <https://www.cdc.gov/flu/weekly/fluviewinteractive.htm> that you want and that isn't in the package, please file it as an issue and be as specific as you can (screen shot if possible).
------------------------------------------------------------------------
The U.S. Centers for Disease Control (CDC) maintains a [portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html) for accessing state, regional and national influenza statistics. The portal's Flash interface makes it difficult and time-consuming to select and retrieve influenza data. This package provides functions to access the data provided by the portal's underlying API.
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/cdcfluview)](https://cran.r-project.org/package=cdcfluview)
[![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/cdcfluview.svg?branch=master)](https://travis-ci.org/hrbrmstr/cdcfluview)
[![Coverage
Status](https://img.shields.io/codecov/c/github/hrbrmstr/cdcfluview/master.svg)](https://codecov.io/github/hrbrmstr/cdcfluview?branch=master)
I M P O R T A N T
=================
The CDC migrated to a new non-Flash portal and back-end APIs changed.
This is a complete reimagining of the package and — as such — all your
code is going to break. Please use GitHub issues to identify previous
API functionality you would like ported over. There’s a [release
candidate for
0.5.2](https://github.com/hrbrmstr/cdcfluview/releases/tag/v0.5.2) which
uses the old API but it likely to break in the near future given the
changes to the hidden API. You can do what with
`devtools::install_github("hrbrmstr/cdcfluview", ref="58c172b")`.
All folks providing feedback, code or suggestions will be added to the
DESCRIPTION file. Please include how you would prefer to be cited in any
issues you file.
If there’s a particular data set from
<https://www.cdc.gov/flu/weekly/fluviewinteractive.htm> that you want
and that isn’t in the package, please file it as an issue and be as
specific as you can (screen shot if possible).
:mask: cdcfluview
=================
Retrieve U.S. Flu Season Data from the CDC FluView Portal
Description
-----------
The U.S. Centers for Disease Control (CDC) maintains a portal
<http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html> for accessing
state, regional and national influenza statistics as well as Mortality
Surveillance Data. The Flash interface makes it difficult and
time-consuming to select and retrieve influenza data. This package
provides functions to access the data provided by the portal’s
underlying API.
What’s Inside The Tin
---------------------
The following functions are implemented:
- `get_flu_data`: Retrieves state, regional or national influenza statistics from the CDC
- `get_state_data`: Retrieves state/territory-level influenza statistics from the CDC
- `get_weekly_flu_report`: Retrieves (high-level) weekly influenza surveillance report from the CDC
- `get_mortality_surveillance_data` : (fairly self explanatory but also pretty new to the pkg and uses data from: <https://www.cdc.gov/flu/weekly/nchs.htm>
- `agd_ipt`: Age Group Distribution of Influenza Positive Tests
Reported by Public Health Laboratories
- `cdcfluview`: Tools to Work with the ‘CDC’ ‘FluView’ ‘API’
- `cdc_coverage_map`: Retrieve CDC U.S. Coverage Map
- `geographic_spread`: State and Territorial Epidemiologists Reports
of Geographic Spread of Influenza
- `hospitalizations`: Laboratory-Confirmed Influenza Hospitalizations
- `ilinet`: Retrieve ILINet Surveillance Data
- `ili_weekly_activity_indicators`: Retrieve weekly state-level ILI
indicators per-state for a given season
- `pi_mortality`: Pneumonia and Influenza Mortality Surveillance
- `state_data_providers`: Retrieve metadat about U.S. State CDC
Provider Data
- `surveillance_areas`: Retrieve a list of valid sub-regions for each
surveillance area.
- `who_nrevss`: Retrieve WHO/NREVSS Surveillance Data
The following data sets are included:
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4 variables)
- `census_regions` Census Region Table (a data frame with 51 rows and 2 variables)
### News
- `hhs_regions` HHS Region Table (a data frame with 59 rows and 4
variables)
- `census_regions` Census Region Table (a data frame with 51 rows and
2 variables)
- See NEWS
- Version 0.4.0 - [CRAN release](http://cran.r-project.org/web/packages/cdcfluview)
- Version 0.4.0.999 released : another fix for the CDC API (for region parameter); added data files for HHS/Census region lookups; added weekly high-level flu report retrieval
- Version 0.3 released : fix for the CDC API (it changed how year & region params are encoded in the request)
- Version 0.2.1 released : bumped up `httr` version \# requirement in `DESCRIPTION` (via Issue [1](https://github.com/hrbrmstr/cdcfluview/issues/1))
- Version 0.2 released : added state-level data retrieval
- Version 0.1 released
### Installation
Installation
------------
``` r
install.packages("cdcfluview")
# **OR**
devtools::install_github("hrbrmstr/cdcfluview")
```
### Usage
Usage
-----
``` r
library(cdcfluview)
library(ggplot2)
library(dplyr)
library(statebins)
# current verison
packageVersion("cdcfluview")
#> [1] '0.5.2'
flu <- get_flu_data("hhs", sub_region=1:10, "ilinet", years=2014)
glimpse(flu)
#> Observations: 530
#> Variables: 15
#> $ REGION TYPE <chr> "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions", "HHS Regions",...
#> $ REGION <chr> "Region 1", "Region 2", "Region 3", "Region 4", "Region 5", "Region 6", "Region 7", "Regi...
#> $ YEAR <int> 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,...
#> $ WEEK <int> 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 4...
#> $ % WEIGHTED ILI <dbl> 0.830610, 1.795830, 1.162260, 0.828920, 0.744546, 1.604740, 0.697022, 0.635856, 1.793140,...
#> $ %UNWEIGHTED ILI <dbl> 0.681009, 1.649790, 1.321020, 0.911243, 1.013950, 1.647270, 0.437619, 0.813397, 1.501530,...
#> $ AGE 0-4 <int> 101, 869, 395, 331, 358, 446, 50, 76, 310, 22, 109, 837, 403, 355, 338, 540, 57, 57, 335,...
#> $ AGE 25-49 <int> 44, 363, 455, 187, 181, 410, 43, 49, 220, 7, 37, 349, 465, 244, 182, 451, 56, 87, 225, 20...
#> $ AGE 25-64 <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
#> $ AGE 5-24 <int> 185, 757, 627, 530, 400, 636, 98, 154, 577, 30, 199, 676, 669, 772, 443, 741, 124, 148, 5...
#> $ AGE 50-64 <int> 13, 157, 126, 80, 80, 111, 15, 19, 110, 1, 24, 151, 130, 74, 105, 168, 18, 23, 118, 10, 2...
#> $ AGE 65 <int> 9, 107, 89, 46, 64, 77, 14, 8, 112, 1, 17, 115, 75, 64, 48, 97, 14, 12, 103, 3, 9, 114, 8...
#> $ ILITOTAL <int> 352, 2253, 1692, 1174, 1083, 1680, 220, 306, 1329, 61, 386, 2128, 1742, 1509, 1116, 1997,...
#> $ NUM. OF PROVIDERS <int> 146, 276, 234, 299, 261, 226, 84, 119, 237, 55, 150, 265, 232, 306, 271, 235, 84, 115, 24...
#> $ TOTAL PATIENTS <int> 51688, 136563, 128083, 128835, 106810, 101987, 50272, 37620, 88510, 11172, 51169, 131884,...
state_flu <- get_state_data(years=2015)
glimpse(state_flu)
#> Observations: 2,807
#> Variables: 8
#> $ statename <chr> "Virgin Islands", "District of Columbia", "Virgin Islands", "District of Columbia", "V...
#> $ url <chr> "http://doh.vi.gov/", "http://doh.dc.gov/page/influenza-season", "http://doh.vi.gov/",...
#> $ website <chr> "Influenza", "Influenza Information", "Influenza", "Influenza Information", "Influenza...
#> $ activity_level <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
#> $ activity_level_label <chr> "Insufficient Data", "Insufficient Data", "Insufficient Data", "Insufficient Data", "I...
#> $ weekend <chr> "Oct-10-2015", "Oct-17-2015", "Oct-17-2015", "Oct-24-2015", "Oct-24-2015", "Oct-31-201...
#> $ season <chr> "2015-16", "2015-16", "2015-16", "2015-16", "2015-16", "2015-16", "2015-16", "2015-16"...
#> $ weeknumber <int> 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51...
gg <- ggplot(flu, aes(x=WEEK, y=`% WEIGHTED ILI`, group=REGION))
gg <- gg + geom_line()
gg <- gg + facet_wrap(~REGION, ncol=2)
gg <- gg + theme_bw()
gg
```
<img src="README_files/README-state2015-1.png" width="576" />
``` r
msd <- get_mortality_surveillance_data()
mutate(msd$by_state, ym=as.Date(sprintf("%04d-%02d-1", Year, Week), "%Y-%U-%u")) %>%
select(state, wk=ym, death_pct=`Percent of Deaths Due to Pneumonia and Influenza`) %>%
mutate(death_pct=death_pct/100) -> df
gg <- ggplot() + geom_smooth(data=df, aes(wk, death_pct, group=state),
se=FALSE, color="#2b2b2b", size=0.25)
gb <- ggplot_build(gg)
gb$data[[1]] %>%
arrange(desc(x)) %>%
group_by(group) %>%
slice(1) %>%
ungroup() %>%
arrange(desc(y)) %>%
head(1) -> top
top_state <- sort(unique(msd$by_state$state))[top$group]
gg <- gg + geom_text(data=top, aes(as.Date(x, origin="1970-01-01"), y, label=top_state),
hjust=1, family="Arial Narrow", size=3, nudge_x=-5, nudge_y=-0.001)
gg <- gg + scale_x_date(expand=c(0,0))
gg <- gg + scale_y_continuous(label=scales::percent)
gg <- gg + labs(x=NULL, y=NULL,
title="Percent of In-State Deaths Due to Pneumonia and Pnfluenza (2010-Present)")
gg <- gg + theme_bw(base_family="Arial Narrow")
gg <- gg + theme(axis.text.x=element_text(margin=margin(0,0,0,0)))
gg <- gg + theme(axis.text.y=element_text(margin=margin(0,0,0,0)))
gg <- gg + theme(axis.ticks=element_blank())
gg <- gg + theme(plot.title=element_text(face="bold", size=16))
gg
```
<img src="README_files/README-mortality-1.png" width="960" />
## [1] '0.7.0'
``` r
gg_s <- state_flu %>%
filter(weekend=="Jan-02-2016") %>%
select(state=statename, value=activity_level) %>%
filter(!(state %in% c("Puerto Rico", "New York City"))) %>% # need to add PR to statebins
mutate(value=as.numeric(gsub("Level ", "", value))) %>%
statebins(brewer_pal="RdPu", breaks=4,
labels=c("Minimal", "Low", "Moderate", "High"),
legend_position="bottom", legend_title="ILI Activity Level") +
ggtitle("CDC State FluView (2015-01-03)")
gg_s
```
### EXAMPLES COMING SOON
<img src="README_files/README-bins-1.png" width="672" />
Code of Conduct
---------------
### Test Results
``` r
library(cdcfluview)
library(testthat)
date()
#> [1] "Tue Mar 14 09:59:29 2017"
test_dir("tests/")
#> testthat results ========================================================================================================
#> OK: 2 SKIPPED: 0 FAILED: 0
#>
#> DONE ===================================================================================================================
```
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.

2
cdcfluview.Rproj

@ -3,7 +3,6 @@ Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: No
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
@ -20,5 +19,4 @@ PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace
QuitChildProcessesOnExit: Yes

22
man/agd_ipt.Rd

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/agd-ipt.r
\name{agd_ipt}
\alias{agd_ipt}
\title{Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories}
\usage{
agd_ipt()
}
\description{
Retrieves the age group distribution of influenza positive tests that are reported by
public health laboratories by influenza virus type and subtype/lineage. Laboratory data
from multiple seasons and different age groups is provided.
}
\examples{
\dontrun{
agd_ipt()
}
}
\references{
- [CDC FluView Portal](https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html)
- [AGD IPT Portal](https://gis.cdc.gov/grasp/fluview/flu_by_age_virus.html)
}

32
man/cdc_coverage_map.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coverage-map.r
\name{cdc_coverage_map}
\alias{cdc_coverage_map}
\title{Retrieve CDC U.S. Coverage Map}
\usage{
cdc_coverage_map()
}
\description{
The CDC FluView application uses a composite basemap of coverage areas
within the United States that elides and scales Alaska, Hawaii and
Puerto Rico and provides elided and scaled breakouts for New York City
and the District of Columbia.\cr
\cr
The basemap provides polygon identifiers by:
\cr
\itemize{
\item \code{STATE_FIPS}
\item \code{STATE_ABBR}
\item \code{STATE_NAME}
\item \code{HHS_Region}
\item \code{FIPSTXT})
\cr
This function retrieves the shapefile, projects to EPSG:5069 and
returns it as an \code{sf} (simple features) object.
}
}
\examples{
\dontrun{
plot(cdc_coverage_map())
}
}

18
man/cdcfluview.Rd

@ -1,18 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cdcfluview-package.R
\docType{package}
\name{cdcfluview}
\alias{cdcfluview}
\alias{cdcfluview-package}
\title{Retrieve Flu Season Data from the CDC FluView Portal}
\description{
The U.S. Centers for Disease Control (CDC) maintains a portal
\code{https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html} for
accessing state, regional and national influenza statistics as well as
Mortality Surveillance Data. The Flash interface makes it difficult
and time-consuming to select and retrieve influenza data. This package
provides functions to access the data provided by portal's underlying API.
}
\author{
Bob Rudis (bob@rud.is)
}

16
man/geographic_spread.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geographic-spread.R
\name{geographic_spread}
\alias{geographic_spread}
\title{State and Territorial Epidemiologists Reports of Geographic Spread of Influenza}
\usage{
geographic_spread()
}
\description{
State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
}
\examples{
\dontrun{
geographic_spread()
}
}

32
man/hospitalizations.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hospital.r
\name{hospitalizations}
\alias{hospitalizations}
\title{Laboratory-Confirmed Influenza Hospitalizations}
\usage{
hospitalizations(surveillance_area = c("flusurv", "eip", "ihsp"),
region = "all")
}
\arguments{
\item{surveillance_area}{one of "\code{flusurv}", "\code{eip}", or "\code{ihsp}"}
\item{region}{Using "\code{all}" mimics selecting "Entire Network" from the
CDC FluView application drop down. Individual regions for each
surveillance area can also be selected. Use \code{\link[=surveillance_areas]{surveillance_areas()}} to
see a list of valid sub-regions for each surveillance area.}
}
\description{
Laboratory-Confirmed Influenza Hospitalizations
}
\examples{
\dontrun{
hosp_fs <- hospitalizations("flusurv")
hosp_eip <- hospitalizations("eip")
hosp_ihsp <- hospitalizations("ihsp")
}
}
\references{
\itemize{
\item \href{https://gis.cdc.gov/GRASP/Fluview/FluHospRates.html}{Hospital Portal}
}
}

39
man/ili_weekly_activity_indicators.Rd

@ -0,0 +1,39 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ili-weekly-state.r
\name{ili_weekly_activity_indicators}
\alias{ili_weekly_activity_indicators}
\title{Retrieve weekly state-level ILI indicators per-state for a given season}
\usage{
ili_weekly_activity_indicators(season_start_year)
}
\arguments{
\item{season_start_year}{numeric; start year for flu season (e.g. 2017 for 2017-2018 season)}
}
\description{
Retrieve weekly state-level ILI indicators per-state for a given season
}
\note{
These statistics use the proportion of outpatient visits to healthcare providers
for influenza-like illness to measure the ILI activity level within a state. They do
not, however, measure the extent of geographic spread of flu within a state. Therefore,
outbreaks occurring in a single city could cause the state to display high activity levels.\cr
\cr
Data collected in ILINet may disproportionately represent certain populations within
a state, and therefore may not accurately depict the full picture of influenza activity
for the whole state.\cr
\cr
All summary statistics are based on either data collected in ILINet, or reports from
state and territorial epidemiologists. Differences in the summary data presented by
CDC and state health departments likely represent differing levels of data completeness
with data presented by the state likely being the more complete.
}
\examples{
\dontrun{
ili_weekly_activity_indicators(2016)
}
}
\references{
\itemize{
\item \href{https://gis.cdc.gov/grasp/fluview/main.html}{ILI Activity Indicator Map Portal}
}
}

40
man/ilinet.Rd

@ -0,0 +1,40 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ilinet.r
\name{ilinet}
\alias{ilinet}
\title{Retrieve ILINet Surveillance Data}
\usage{
ilinet(region = c("national", "hhs", "census", "state"))
}
\arguments{
\item{region}{one of "\code{national}", "\code{hhs}", "\code{census}", or "\code{state}"}
}
\description{
The CDC FluView Portal provides in-season and past seasons' national, regional,
and state-level outpatient illness and viral surveillance data from both
ILINet (Influenza-like Illness Surveillance Network) and WHO/NREVSS
(National Respiratory and Enteric Virus Surveillance System).
}
\details{
This function retrieves current and historical ILINet surveillance data for
the identified region.
}
\examples{
national_ili <- ilinet("national")
hhs_ili <- ilinet("hhs")
census_ili <- ilinet("census")
state_ili <- ilinet("state")
\dontrun{
library(purrr)
map_df(
c("national", "hhs", "census", "state"),
~ilinet(.x) \%>\% readr::type_convert())
}
}
\references{
\itemize{
\item \href{https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html}{CDC FluView Portal}
\item \href{https://wwwn.cdc.gov/ilinet/}{ILINet Portal} (Login required)
\item \href{https://www.cdc.gov/surveillance/nrevss/index.html}{WHO/NREVSS}
}
}

54
man/pi_mortality.Rd

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pi-mortality.r
\name{pi_mortality}
\alias{pi_mortality}
\title{Pneumonia and Influenza Mortality Surveillance}
\usage{
pi_mortality(coverage_area = c("national", "state", "region"))
}
\arguments{
\item{coverage_area}{coverage area for data (national, state or region)}
}
\description{
The National Center for Health Statistics (NCHS) collects and disseminates the Nation's
official vital statistics. NCHS collects death certificate data from state vital
statistics offices for virtually all deaths occurring in the United States. Pneumonia
and influenza (P&I) deaths are identified based on ICD-10
multiple cause of death codes.\cr
\cr
NCHS Mortality Surveillance System data are presented by the week the death occurred
at the national, state, and HHS Region levels. Data on the percentage of deaths due
to P&I on a national level are released two weeks after the week of death to allow
for collection of enough data to produce a stable percentage. States and HHS regions
with less than 20% of the expected total deaths (average number of total deaths
reported by week during 2008-2012) will be marked as insufficient data. Collection
of complete data is not expected at the time of initial report, and a reliable
percentage of deaths due to P&I is not anticipated at the U.S. Department of Health
and Human Services region or state level within this two week period. The data for
earlier weeks are continually revised and the proportion of deaths due to P&I may
increase or decrease as new and updated death certificate data are received by NCHS.\cr
\cr
The seasonal baseline of P&I deaths is calculated using a periodic regression model
that incorporates a robust regression procedure applied to data from the previous
five years. An increase of 1.645 standard deviations above the seasonal baseline
of P&I deaths is considered the "epidemic threshold," i.e., the point at which
the observed proportion of deaths attributed to pneumonia or influenza was
significantly higher than would be expected at that time of the year in the
absence of substantial influenza-related mortality. Baselines and thresholds are
calculated at the national and regional level and by age group.
}
\note{
Queries for "state" and "region" are not "instantaneous" and can near or over 30s retrieval delays.
}
\examples{
\dontrun{
ndf <- pi_mortality()
sdf <- pi_mortality("state")
rdf <- pi_mortality("region")
}
}
\references{
\itemize{
\item \href{https://gis.cdc.gov/grasp/fluview/mortality.html}{Pneumonia and Influenza Mortality Surveillance Portal}
}
}

14
man/state_data_providers.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ili-weekly-state.r
\name{state_data_providers}
\alias{state_data_providers}
\title{Retrieve metadat about U.S. State CDC Provider Data}
\usage{
state_data_providers()
}
\description{
Retrieve metadat about U.S. State CDC Provider Data
}
\examples{
state_data_providers()
}

14
man/surveillance_areas.Rd

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hospital.r
\name{surveillance_areas}
\alias{surveillance_areas}
\title{Retrieve a list of valid sub-regions for each surveillance area.}
\usage{
surveillance_areas()
}
\description{
Retrieve a list of valid sub-regions for each surveillance area.
}
\examples{
surveillance_areas()
}

51
man/who_nrevss.Rd

@ -0,0 +1,51 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/who-nrvess.r
\name{who_nrevss}
\alias{who_nrevss}
\title{Retrieve WHO/NREVSS Surveillance Data}
\usage{
who_nrevss(region = c("national", "hhs", "census", "state"))
}
\arguments{
\item{region}{one of "\code{national}", "\code{hhs}", "\code{census}", or "\code{state}"}
}
\value{
list of data frames identified by
\itemize{
\item \code{combined_prior_to_2015_16}
\item \code{public_health_labs}
\item \code{clinical_labs}
}
}
\description{
The CDC FluView Portal provides in-season and past seasons' national, regional,
and state-level outpatient illness and viral surveillance data from both
ILINet (Influenza-like Illness Surveillance Network) and WHO/NREVSS
(National Respiratory and Enteric Virus Surveillance System).
}
\details{
This function retrieves current and historical WHO/NREVSS surveillance data for
the identified region.
}
\note{
HHS, Census and State data retrieval is not as "instantaneous" as their ILINet
counterparts.\cr\cr
Also, beginning for the 2015-16 season, reports from public health and clinical
laboratories are presented separately in the weekly influenza update. This is
the reason why a list of data frames is returned.
}
\examples{
\dontrun{
national_who <- who_nrevss("national")
hhs_who <- who_nrevss("hhs")
census_who <- who_nrevss("census")
state_who <- who_nrevss("state")
}
}
\references{
\itemize{
\item \href{https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html}{CDC FluView Portal}
\item \href{https://wwwn.cdc.gov/ilinet/}{ILINet Portal} (Login required)
\item \href{https://www.cdc.gov/surveillance/nrevss/index.html}{WHO/NREVSS}
}
}

22
tests/testthat/test-cdcfluview.R

@ -1,24 +1,4 @@
context("basic functionality")
test_that("we can do something", {
skip_on_cran()
expect_that(dim(get_flu_data("hhs", years=2015)), equals(c(520L, 15L)))
expect_that(dim(get_state_data(2008)), equals(c(2494L, 8L)))
invisible(get_flu_data())
invisible(get_flu_data(data_source="all"))
invisible(get_weekly_flu_report())
})
test_that("these are potentially time-consuming calls", {
skip_on_cran()
invisible(get_mortality_surveillance_data())
#expect_that(some_function(), is_a("data.frame"))
})
Loading…
Cancel
Save