View source: R/textstat_polarity.R
polarity | R Documentation |
Set or retrieve the polarity of a dictionary object for the purposes of
sentiment analysis. Polarity consists of a set of dictionary keys that are
associated with positive, negative, and (optionally) neutral categories for
use in textstat_polarity()
.
polarity(x)
polarity(x) <- value
x |
a dictionary object |
value |
list consisting of named character vectors |
A dictionary may have only one set of polarities at a time, but may be changed as needed.
polarity()
returns the polarity as a list.
polarity<-
sets the dictionary's polarity.
library("quanteda")
simpledict <- dictionary(list(
happy = c("happy", "jubilant", "exuberant"),
sad = c("sad", "morose", "down")
))
polarity(simpledict)
polarity(simpledict) <- list(pos = "happy", neg = "sad")
polarity(simpledict)
# can list multiple keys
polarity(data_dictionary_LSD2015) <- list(
pos = c("positive", "neg_negative"),
neg = c("negative", "neg_positive")
)
polarity(data_dictionary_LSD2015)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.