You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.4 KiB

7 years ago
---
title: ""
pagetitle: ""
7 years ago
output: rmarkdown::github_document
---
[![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
7 years ago
## 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.
7 years ago
## What's Inside The Tin
The following functions are implemented:
- `age_group_distribution`: Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
- `cdc_basemap`: Retrieve CDC U.S. Basemaps
- `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 metadata 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)
7 years ago
## Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/cdcfluview")
```
```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```
## Usage
```{r message=FALSE, warning=FALSE, error=FALSE}
library(cdcfluview)
library(hrbrthemes)
7 years ago
library(tidyverse)
7 years ago
# current verison
packageVersion("cdcfluview")
```
7 years ago
### Age Group Distribution of Influenza Positive Tests Reported by Public Health Laboratories
```{r message=FALSE, warning=FALSE}
glimpse(age_group_distribution())
7 years ago
```
### Retrieve CDC U.S. Coverage Map
```{r message=FALSE, warning=FALSE}
plot(cdc_basemap("national"))
plot(cdc_basemap("hhs"))
plot(cdc_basemap("census"))
plot(cdc_basemap("states"))
plot(cdc_basemap("spread"))
plot(cdc_basemap("surv"))
7 years ago
```
### State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
```{r message=FALSE, warning=FALSE}
glimpse(geographic_spread())
```
### Laboratory-Confirmed Influenza Hospitalizations
```{r message=FALSE, warning=FALSE}
surveillance_areas()
glimpse(hospitalizations("flusurv"))
glimpse(hospitalizations("eip"))
glimpse(hospitalizations("eip", "Colorado"))
glimpse(hospitalizations("ihsp"))
glimpse(hospitalizations("ihsp", "Oklahoma"))
```
### Retrieve ILINet Surveillance Data
```{r message=FALSE, warning=FALSE}
walk(c("national", "hhs", "census", "state"), ~{
ili_df <- ilinet(region = .x)
print(glimpse(ili_df))
ggplot(ili_df, aes(week_start, unweighted_ili, group=region, color=region)) +
geom_line() +
viridis::scale_color_viridis(discrete=TRUE) +
labs(x=NULL, y="Unweighted ILI", title=ili_df$region_type[1]) +
theme_ipsum_rc(grid="XY") +
theme(legend.position = "none") -> gg
print(gg)
})
7 years ago
```
### Retrieve weekly state-level ILI indicators per-state for a given season
```{r message=FALSE, warning=FALSE}
ili_weekly_activity_indicators(2017)
ili_weekly_activity_indicators(2015)
```
### Pneumonia and Influenza Mortality Surveillance
```{r message=FALSE, warning=FALSE}
pi_mortality("national")
pi_mortality("state")
pi_mortality("region")
```
### Retrieve metadata about U.S. State CDC Provider Data
7 years ago
```{r message=FALSE, warning=FALSE}
state_data_providers()
```
### Retrieve WHO/NREVSS Surveillance Data
```{r message=FALSE, warning=FALSE}
who_nrevss("national")
who_nrevss("hhs")
who_nrevss("census")
who_nrevss("state")
```
## 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.