Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. sentiment_words <- tidy_df %>%
  2. inner_join(get_sentiments("bing")) %>%
  3. count(genre, word, sentiment, sort = TRUE) %>%
  4. ungroup()
  5.  
  6. sentiment_words %>%
  7. group_by(genre, sentiment) %>%
  8. top_n(5) %>%
  9. ungroup() %>%
  10. mutate(word = reorder(word, n)) %>%
  11. ggplot(aes(word, n, fill = sentiment)) +
  12. geom_col(show.legend = FALSE) +
  13. facet_wrap(~genre, scales = "free_y") +
  14. labs(y = "Contribution to sentiment",
  15. x = NULL) +
  16. coord_flip() +
  17. ggtitle('Figure 6: Words contributing to sentiments per genre')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement