Guest User

Untitled

a guest
Nov 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # select top 100 words by avg rank
  2. hn_counts_and_ranks %>% top_n(100, wt = avg_rank) %>%
  3.  
  4. # construct plot
  5. ggplot(aes(avg_rank, n, label = word)) +
  6. geom_text_repel(segment.alpha = 0, aes(colour=avg_rank,
  7. size=n)) +
  8. scale_color_gradient(low="green3", high="violetred", trans = "log10",
  9. guide = guide_colourbar(direction = "horizontal",
  10. title.position ="top")) +
  11. scale_size_continuous(range = c(3, 10),
  12. guide = FALSE) +
  13. scale_x_log10() +
  14. ggtitle(paste0("Top 100 words from ",
  15. nrow(hn_comments),
  16. " Hacker News article comments, by average ranking"),
  17. subtitle = "word frequency (size) ~ avg comment ranking (color)") +
  18. labs(y = "Word frequency", x = "Avg rank (log scale)") +
  19. theme_minimal() +
  20. theme(legend.position=c(.99, .99),
  21. legend.justification = c("right","top"),
  22. panel.grid.major = element_line(colour = "whitesmoke"))
Add Comment
Please, Sign In to add comment