Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dslabs)
- library(tidyverse)
- data(us_contagious_diseases)
- the_disease <- "Measles"
- min_weeks_reporting <- 10
- dat <- us_contagious_diseases %>%
- filter(
- disease == the_disease &
- weeks_reporting >= min_weeks_reporting &
- !is.na(population)
- ) %>%
- mutate(rate = count / population * 10000 * 52 / weeks_reporting)
- dat %>% ggplot(aes(year, state, fill = rate)) +
- geom_tile(color="grey40")+
- scale_x_continuous(expand=c(0,0)) +
- scale_fill_gradientn(colors = RColorBrewer::brewer.pal(9, "Reds"), trans = "sqrt") +
- geom_vline(xintercept=1963, col = "blue") +
- theme_minimal() +
- theme(panel.grid = element_blank()) +
- ggtitle(the_disease) +
- ylab("") +
- xlab("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement