Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- frequency <- bind_rows(mutate(tidy_df %>%
- filter(artist == 'Eminem'), author = 'Eminem'),
- mutate(tidy_df %>%
- filter(artist == 'Adele'), author = 'Adele'),
- mutate(tidy_df %>%
- filter(artist == 'Metallica'), author = 'Metallica')) %>%
- count(author, word) %>%
- group_by(author) %>%
- mutate(proportion = n/ sum(n)) %>%
- select(-n) %>%
- spread(author, proportion) %>%
- gather(author, proportion, `Eminem`:`Adele`)
- library(scales)
- ggplot(frequency, aes(x = proportion, y = `Metallica`, color = abs(`Metallica` - proportion))) +
- geom_abline(color = "gray40", lty = 2) +
- ggtitle("Figure 3: Different word choices") +
- geom_jitter(alpha = 0.1, size = 2.5, width = 0.3, height = 0.3) +
- geom_text(aes(label = word), check_overlap = TRUE, vjust = 1.5) +
- scale_x_log10(labels = percent_format()) +
- scale_y_log10(labels = percent_format()) +
- scale_color_gradient(limits = c(0, 0.001),
- low = "darkslategray4", high = "gray75") +
- facet_wrap(~author, ncol = 2) +
- theme(legend.position = "none") +
- labs(y = 'Metallica', x = NULL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement