Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. library(tidyverse)
  2. library(googlesheets) # reading the data
  3. library(statebins) # mapping wrapper
  4.  
  5. # load data by publig googlesheets key
  6. states <- gs_key("1Fb0YmrM7IX9wuQ047oQU6pNj1osWsz7sWKS4wgIFJGA")
  7. states_gs <- gs_read(ss = states, ws = 1)
  8.  
  9. # recode values in preferred order
  10. st_raw <- states_gs %>%
  11. mutate(is_yes = recode(centralized,
  12. `yes` = 5,
  13. `no` = 3,
  14. `partial` = 4,
  15. `other` = 2,
  16. .default = 1))
  17.  
  18. # plot with statebins, a wrapper to ggplot
  19. statebins(state_data = st_raw,
  20. value_col = "is_yes",
  21. labels = rev(c("Yes", "Partial", "No", NA, "No response")),
  22. legend_title = "State collect CVRs from counties?",
  23. brewer_pal = "Oranges") +
  24. labs(caption = "Responses as of 2019-07-11")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement