Polarité tidy avec Bing : Call me Ishmael (avec ggplot2) !
Dernier exercice sur le lexique Bing ! Dans cet exercice, vous allez utiliser l'opérateur pipe (%>%) pour créer une chronologie du sentiment dans Moby Dick.
À la fin, vous créerez aussi un visuel simple en suivant la structure de code ci-dessous. Le chapitre suivant approfondira les visuels.
ggplot(pivoted_data, aes(index_column, polarity_column)) +
geom_smooth(se = FALSE)
Cet exercice fait partie du cours
<cours>Analyse de sentiments en R</cours>Exercice interactif pratique
Essayez cet exercice en complétant ce code d’exemple.
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,]