Bing tidy 極性:Call me Ishmael(搭配 ggplot2)!
最後一個 Bing 詞彙庫的練習!在本題中,你會使用 pipe 運算子(%>%)為《白鯨記》(Moby Dick)建立情緒時間軸。
最後你也會依照下方的程式碼結構,建立一個簡單的視覺化。下一章會更深入介紹視覺化。
ggplot(pivoted_data, aes(index_column, polarity_column)) +
geom_smooth(se = FALSE)
本練習屬於課程
R 情感分析
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
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,]