daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(dslabs)
  2. library(tidyverse)
  3. data(us_contagious_diseases)
  4. the_disease <- "Measles"
  5. min_weeks_reporting <- 10
  6. dat <- us_contagious_diseases %>%
  7.   filter(
  8.     disease == the_disease &
  9.       weeks_reporting >= min_weeks_reporting &
  10.       !is.na(population)
  11.   ) %>%
  12.   mutate(rate = count / population * 10000 * 52 / weeks_reporting)
  13. dat %>% ggplot(aes(year, state, fill = rate)) +
  14.   geom_tile(color="grey40")+
  15.   scale_x_continuous(expand=c(0,0)) +
  16.   scale_fill_gradientn(colors = RColorBrewer::brewer.pal(9, "Reds"), trans = "sqrt") +
  17.   geom_vline(xintercept=1963, col = "blue") +
  18.   theme_minimal() +  
  19.   theme(panel.grid = element_blank()) +
  20.   ggtitle(the_disease) +
  21.   ylab("") +
  22.   xlab("")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top