Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sentiment_words <- tidy_df %>%
- inner_join(get_sentiments("bing")) %>%
- count(genre, word, sentiment, sort = TRUE) %>%
- ungroup()
- sentiment_words %>%
- group_by(genre, sentiment) %>%
- top_n(5) %>%
- ungroup() %>%
- mutate(word = reorder(word, n)) %>%
- ggplot(aes(word, n, fill = sentiment)) +
- geom_col(show.legend = FALSE) +
- facet_wrap(~genre, scales = "free_y") +
- labs(y = "Contribution to sentiment",
- x = NULL) +
- coord_flip() +
- ggtitle('Figure 6: Words contributing to sentiments per genre')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement