|
|
|
---
|
|
|
|
title: "README"
|
|
|
|
author: "Bob Rudis"
|
|
|
|
date: January 11, 2015
|
|
|
|
output:
|
|
|
|
md_document:
|
|
|
|
variant: markdown_github
|
|
|
|
---
|
|
|
|
|
|
|
|
The CDC's FluView is a Flash portal and the only way to get flu season
|
|
|
|
data is to use GUI controls, making it tedious to retrieve updates. This package
|
|
|
|
uses the same API the portal does to programmatically retrieve data.
|
|
|
|
|
|
|
|
The following functions are implemented:
|
|
|
|
|
|
|
|
- `get_flu_data` : retrieve flu data (national, by various region/sub-region types)
|
|
|
|
- `get_state_data` : retrieve state-level flu data
|
|
|
|
|
|
|
|
The following data sets are included:
|
|
|
|
|
|
|
|
### News
|
|
|
|
|
|
|
|
- Version 0.1 released
|
|
|
|
- Version 0.2 releases : added state-level data retrieval
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
```{r eval=FALSE}
|
|
|
|
devtools::install_github("hrbrmstr/cdcfluview")
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
|
|
|
|
options(width=120)
|
|
|
|
```
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
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()
|
|
|
|
glimpse(state_flu)
|
|
|
|
|
|
|
|
gg <- ggplot(flu, aes(x=WEEK, y=X..WEIGHTED.ILI, group=REGION))
|
|
|
|
gg <- gg + geom_line()
|
|
|
|
gg <- gg + facet_wrap(~REGION, ncol=2)
|
|
|
|
gg <- gg + theme_bw()
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r echo=FALSE, fig.height=10, fig.width=6}
|
|
|
|
gg
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
gg_s <- state_flu %>%
|
|
|
|
filter(WEEKEND=="Jan-03-2015") %>%
|
|
|
|
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)")
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r echo=FALSE, fig.height=5, fig.width=7}
|
|
|
|
gg_s
|
|
|
|
```
|
|
|
|
|
|
|
|
### Test Results
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
library(cdcfluview)
|
|
|
|
library(testthat)
|
|
|
|
|
|
|
|
date()
|
|
|
|
|
|
|
|
test_dir("tests/")
|
|
|
|
```
|
|
|
|
|