I used tidytext and ggplot to compute and plot bigram frequencies (and tf-idfs). I've plotted the most frequent bigrams across four time periods. However, I can't figure out how to correctly sort my counts in all four plots.
This is the code I used:
bigram_tf_idf_plot %>%
arrange(desc(n)) %>%
mutate(bigram = factor(bigram, levels = rev(unique(bigram)))) %>%
group_by(period) %>%
top_n(10, n) %>%
ungroup %>%
ggplot(aes(bigram, n, fill = period)) +
geom_col(show.legend = FALSE) +
labs(x = NULL, y = "n") +
facet_wrap(~period, ncol = 2, scales = "free") +
coord_flip()