开始使用免费开始使用

Bing 整洁极性:Call me Ishmael(配合 ggplot2)!

最后一个 Bing 词典练习!在本练习中,您将使用管道运算符(%>%)为《白鲸》中的情感创建时间线。 最后,您还会按照下面的代码结构创建一个简单的可视化。下一章会更深入地讲解可视化。

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,]
编辑并运行代码