Search code examples
tidytext

Loading Loughran finance sentiment into Tidytext


I'm using the sentiment tools in Tidytext for the first time, and would like to use the Loughran dictionary. After several attempts, the closest I get is this error:

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

Is Loughran a Tidytext offering or must it be externally retrieved/loaded? Thank you.


Solution

  • The Loughran sentiment lexicon is in the version of tidytext that is on GitHub but not yet on CRAN. We will be releasing a new version on CRAN in the near future! In the meantime, you can install the current development version of tidytext from GitHub using devtools:


    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