Aan de slagGa gratis aan de slag

Visualizing the NRC sentiments

We've seen how visualizations can give us a better idea of patterns in data than counts alone. Let's visualize the sentiments from the nrc dictionary. I've loaded the tidyverse and tidytext packages for you already.

Deze oefening maakt deel uit van de cursus

Introduction to Text Analysis in R

Cursus bekijken

Oefeninstructies

  • Extract the nrc dictionary, count the sentiments and reorder them by count to create a new factor column, sentiment2.
  • Visualize sentiment_counts using the new sentiment factor column.
  • Change the title to "Sentiment Counts in NRC", x-axis to "Sentiment", and y-axis to "Counts".

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Pull in the nrc dictionary, count the sentiments and reorder them by count
sentiment_counts <- ___(___) %>% 
  ___(___) %>% 
  ___(sentiment2 = ___(___, ___))

# Visualize sentiment_counts using the new sentiment factor column
___(___, aes(___, ___)) +
  geom_col() +
  coord_flip() +
  # Change the title to "Sentiment Counts in NRC", x-axis to "Sentiment", and y-axis to "Counts"
  ___(
    ___ = ___,
    ___ = ___,
    ___ = ___
  )
Code bewerken en uitvoeren