Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # select top 100 words by avg rank
- hn_counts_and_ranks %>% top_n(100, wt = avg_rank) %>%
- # construct plot
- ggplot(aes(avg_rank, n, label = word)) +
- geom_text_repel(segment.alpha = 0, aes(colour=avg_rank,
- size=n)) +
- scale_color_gradient(low="green3", high="violetred", trans = "log10",
- guide = guide_colourbar(direction = "horizontal",
- title.position ="top")) +
- scale_size_continuous(range = c(3, 10),
- guide = FALSE) +
- scale_x_log10() +
- ggtitle(paste0("Top 100 words from ",
- nrow(hn_comments),
- " Hacker News article comments, by average ranking"),
- subtitle = "word frequency (size) ~ avg comment ranking (color)") +
- labs(y = "Word frequency", x = "Avg rank (log scale)") +
- theme_minimal() +
- theme(legend.position=c(.99, .99),
- legend.justification = c("right","top"),
- panel.grid.major = element_line(colour = "whitesmoke"))
Add Comment
Please, Sign In to add comment