|
|
@ -58,7 +58,7 @@ options(width=120) |
|
|
|
|
|
|
|
### Usage |
|
|
|
|
|
|
|
```{r message=FALSE} |
|
|
|
```{r message=FALSE, warning=FALSE, fig.height=10, fig.width=6} |
|
|
|
library(cdcfluview) |
|
|
|
library(ggplot2) |
|
|
|
library(dplyr) |
|
|
@ -77,9 +77,42 @@ 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 echo=FALSE, fig.height=10, fig.width=6} |
|
|
|
```{r 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 |
|
|
|
``` |
|
|
|
|
|
|
@ -129,11 +162,7 @@ gg <- gg + theme(axis.ticks.x=element_blank()) |
|
|
|
gg <- gg + theme(axis.text.x=element_blank()) |
|
|
|
``` |
|
|
|
|
|
|
|
```{r echo=FALSE, fig.height=10, fig.width=6, warning=FALSE, error=FALSE, message=FALSE} |
|
|
|
gg |
|
|
|
``` |
|
|
|
|
|
|
|
```{r message=FALSE} |
|
|
|
```{r message=FALSE, fig.height=5, fig.width=7} |
|
|
|
gg_s <- state_flu %>% |
|
|
|
filter(WEEKEND=="Jan-03-2015") %>% |
|
|
|
select(state=STATENAME, value=ACTIVITY.LEVEL) %>% |
|
|
@ -143,9 +172,6 @@ gg_s <- state_flu %>% |
|
|
|
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 |
|
|
|
``` |
|
|
|
|
|
|
|