Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. library("tidyverse")
  2. library("readxl")
  3.  
  4. british_pms <- read_excel("data/british-pms.xlsx")
  5. view(british_pms)
  6.  
  7. british_pms %>%
  8. count(birth_month, sort = TRUE) %>%
  9. mutate(birth_month = fct_relevel (birth_month,
  10. month.name)) %>%
  11. ggplot()+
  12. geom_col(aes(x = birth_month,
  13. y = n))
  14.  
  15. british_pms %>%
  16. count(birth_month, sort = TRUE) %>%
  17. mutate(birth_month = fct_reorder (birth_month,
  18. n)) %>%
  19. ggplot()+
  20. geom_col(aes(x = birth_month,
  21. y = n),
  22. fill = "orange") +
  23. scale_y_continuous(expand = c(0, 0))+
  24. coord_flip()
  25.  
  26.  
  27. british_pms %>%
  28. count(birth_month, sort = TRUE) %>%
  29. mutate(birth_month = fct_reorder (birth_month,
  30. n)) %>%
  31. ggplot()+
  32. geom_col(aes(x = birth_month,
  33. y = n),
  34. fill = "orange") +
  35. scale_y_continuous(limits = c(0, 9),
  36. breaks = 1:9,
  37. expand = expand_scale(mult = c(0,0),
  38. add = c(0.1,0)))+
  39. coord_flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement