Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. frequency <- bind_rows(mutate(tidy_df %>%
  2. filter(artist == 'Eminem'), author = 'Eminem'),
  3. mutate(tidy_df %>%
  4. filter(artist == 'Adele'), author = 'Adele'),
  5. mutate(tidy_df %>%
  6. filter(artist == 'Metallica'), author = 'Metallica')) %>%
  7. count(author, word) %>%
  8. group_by(author) %>%
  9. mutate(proportion = n/ sum(n)) %>%
  10. select(-n) %>%
  11. spread(author, proportion) %>%
  12. gather(author, proportion, `Eminem`:`Adele`)
  13.  
  14. library(scales)
  15. ggplot(frequency, aes(x = proportion, y = `Metallica`, color = abs(`Metallica` - proportion))) +
  16. geom_abline(color = "gray40", lty = 2) +
  17. ggtitle("Figure 3: Different word choices") +
  18. geom_jitter(alpha = 0.1, size = 2.5, width = 0.3, height = 0.3) +
  19. geom_text(aes(label = word), check_overlap = TRUE, vjust = 1.5) +
  20. scale_x_log10(labels = percent_format()) +
  21. scale_y_log10(labels = percent_format()) +
  22. scale_color_gradient(limits = c(0, 0.001),
  23. low = "darkslategray4", high = "gray75") +
  24. facet_wrap(~author, ncol = 2) +
  25. theme(legend.position = "none") +
  26. labs(y = 'Metallica', x = NULL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement