将 Loughran 金融情绪加载到 Tidytext 中

Loading Loughran finance sentiment into Tidytext

我是第一次使用 Tidytext 中的情感工具,想使用 Loughran 词典。经过几次尝试,我得到的最接近的是这个错误:

get_sentiments("loughran") Error in get_sentiments("loughran") : could not find function "%>%"

Loughran 是 Tidytext 产品还是必须是外部产品retrieved/loaded?谢谢你。

Loughran 情感词典在 GitHub 但尚未在 CRAN 上的 tidytext 版本中。我们将在不久的将来在 CRAN 上发布新版本!同时,您可以使用 devtools 从 GitHub 安装当前开发版本的 tidytext:


library(devtools)
install_github("juliasilge/tidytext")


library(tidytext)
get_sentiments("loughran")
#> # A tibble: 4,149 × 2
#>            word sentiment
#>           <chr>     <chr>
#> 1       abandon  negative
#> 2     abandoned  negative
#> 3    abandoning  negative
#> 4   abandonment  negative
#> 5  abandonments  negative
#> 6      abandons  negative
#> 7     abdicated  negative
#> 8     abdicates  negative
#> 9    abdicating  negative
#> 10   abdication  negative
#> # ... with 4,139 more rows