Get startedGet started for free

Bing tidy polarity: Call me Ishmael (with ggplot2)!

The last Bing lexicon exercise! In this exercise you will use the pipe operator (%>%) to create a timeline of the sentiment in Moby Dick. In the end you will also create a simple visual following the code structure below. The next chapter goes into more depth for visuals.

ggplot(pivoted_data, aes(index_column, polarity_column)) +
  geom_smooth(se = FALSE)

This exercise is part of the course

Sentiment Analysis in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

moby_polarity <- moby %>%
  # Inner join to lexicon
  ___(bing, by = c("___" = "___")) %>%
  # Count the sentiment scores
  ___(___, ___) %>% 
  # Pivot the sentiment into positive and negative columns
  ___(names_from = ___, values_from = ___, values_fill = ___) %>%
  # Add polarity column
  mutate(___ = ___ - __) %>% arrange(index)

# Examine a portion 
moby_polarity[190:195,]
Edit and Run Code