Radar chart
Remember Plutchik's wheel of emotion? The NRC lexicon has the 8 emotions corresponding to the first ring of the wheel. Previously you created a comparison.cloud() according to the 8 primary emotions. Now you will create a radar chart similar to the wheel in this exercise.
A radarchart is a two-dimensional representation of multidimensional data (at least 3). In this case the tally of the different emotions for a book are represented in the chart. Using a radar chart, you can review all 8 emotions simultaneously.
As before we've loaded the "nrc" lexicon as nrc and moby_huck which is a combined tidy version of both Moby Dick and Huck Finn.
In this exercise you once again use a negated grepl() to remove "positive|negative" emotional classes from the chart. As a refresher here is an example:
object <- tibble %>%
filter(!grepl("positive|negative", column_name))
This exercise reintroduces pivot_wider() which rearranges the tallied emotional words. As a refresher consider this raw data called datacamp.
| people | food | like |
|---|---|---|
| Nicole | bread | 78 |
| Nicole | salad | 66 |
| Ted | bread | 99 |
| Ted | salad | 21 |
If you applied pivot_wider() as in datacamp %>% pivot_wider(names_from = people, values_from = like) the data looks like this.
| food | Nicole | Ted |
|---|---|---|
| bread | 78 | 99 |
| salad | 66 | 21 |
Este exercício faz parte do curso
Sentiment Analysis in R
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Review tail of moby_huck
moby_huck[___:___,]
# Perform join
scores <- moby_huck %>%
# Inner join to lexicon
___(___, by = c("___" = "___"))
# Filter, count and spread the data
scores %>%
# Drop positive or negative sentiments
___(!___("___|___", ___)) %>%
# Count by book and sentiment
count(___, ___) %>%
# Pivot book, using n as values
pivot_wider(names_from = ___, values_from = ___, values_fill = ___)