Learn R Programming

sentometrics (version 0.5.6)

aggregate.sentiment: Aggregate textual sentiment across documents and time

Description

Condenses document-level textual sentiment scores into a panel of textual sentiment measures by aggregating across documents and time. This function is called within sento_measures, applied on the output of compute_sentiment.

Usage

# S3 method for sentiment
aggregate(x, ctr, ...)

Arguments

x

a sentiment object created using compute_sentiment (from a sentocorpus object), or an output from to_sentiment.

ctr

output from a ctr_agg call. The howWithin and nCore elements are ignored.

...

not used.

Value

A sentomeasures object.

See Also

compute_sentiment, ctr_agg, sento_measures

Examples

Run this code
# NOT RUN {
data("usnews", package = "sentometrics")
data("list_lexicons", package = "sentometrics")
data("list_valence_shifters", package = "sentometrics")

# computation of sentiment and aggregation into sentiment measures
corpus <- sento_corpus(corpusdf = usnews)
corpusSample <- quanteda::corpus_sample(corpus, size = 500)
l <- sento_lexicons(list_lexicons[c("LM_en", "HENRY_en")], list_valence_shifters[["en"]])
sent <- compute_sentiment(corpusSample, l, how = "counts")
ctr <- ctr_agg(howTime = c("linear"), by = "year", lag = 3)
sentomeasures <- aggregate(sent, ctr)

# }

Run the code above in your browser using DataLab