ComenzarEmpieza gratis

Word impact, frequency analysis

One of the easiest ways to explore data is with a frequency analysis. Although not difficult, in sentiment analysis this simple method can be surprisingly illuminating. Specifically, you will build a barplot. In this exercise you are once again working with moby and bing to construct your visual.

To get the bars ordered from lowest to highest, you will use a trick with factors. reorder() lets you change the order of factor levels based upon another scoring variable. In this case, you will reorder the factor variable term by the scoring variable polarity.

Este ejercicio forma parte del curso

Sentiment Analysis in R

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

moby_tidy_sentiment <- moby %>% 
  # Inner join to bing lexicon by term = word
  inner_join(bing, by = c("term" = "word")) %>% 
  # Count by term and sentiment, weighted by count
  count(___, ___, wt = ___) %>%
  # Pivot sentiment, using n as values
  pivot_wider(names_from = ___, values_from = ___, values_fill = ___) %>%
  # Mutate to add a polarity column
  mutate(polarity = ___ - ___)

# Review
moby_tidy_sentiment
Editar y ejecutar código