Description Usage Arguments Details Value Author(s) Examples
View source: R/sentomeasures_methods.R
Aggregates sentiment measures by combining across provided lexicons, features, and time weighting
schemes dimensions. For do.global = FALSE
, the combination occurs by taking the mean of the relevant
measures. For do.global = TRUE
, this function aggregates all sentiment measures into a weighted global textual
sentiment measure for each of the dimensions.
1 2 3 4 5 6 7 8 9 10 |
x |
a |
features |
a |
lexicons |
a |
time |
a |
do.global |
a |
do.keep |
a |
... |
not used. |
If do.global = TRUE
, the measures are constructed from weights that indicate the importance (and sign)
along each component from the lexicons
, features
, and time
dimensions. There is no restriction in
terms of allowed weights. For example, the global index based on the supplied lexicon weights ("globLex"
) is obtained
first by multiplying every sentiment measure with its corresponding weight (meaning, the weight given to the lexicon the
sentiment is computed with), then by taking the average per date.
If do.global = FALSE
, a modified sento_measures
object, with the aggregated sentiment
measures, including updated information and statistics, but the original sentiment scores data.table
untouched.
If do.global = TRUE
, a data.table
with the different types of weighted global sentiment measures,
named "globLex"
, "globFeat"
, "globTime"
and "global"
, with "date"
as the first
column. The last measure is an average of the the three other measures.
Samuel Borms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | data("usnews", package = "sentometrics")
data("list_lexicons", package = "sentometrics")
data("list_valence_shifters", package = "sentometrics")
# construct a sento_measures object to start with
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"]])
ctr <- ctr_agg(howTime = c("equal_weight", "linear"),
by = "year", lag = 3)
sento_measures <- sento_measures(corpusSample, l, ctr)
# aggregation across specified components
smAgg <- aggregate(sento_measures,
time = list(W = c("equal_weight", "linear")),
features = list(journals = c("wsj", "wapo")),
do.keep = TRUE)
# aggregation in full
dims <- get_dimensions(sento_measures)
smFull <- aggregate(sento_measures,
lexicons = list(L = dims[["lexicons"]]),
time = list(T = dims[["time"]]),
features = list(F = dims[["features"]]))
# "global" aggregation
smGlobal <- aggregate(sento_measures, do.global = TRUE,
lexicons = c(0.3, 0.1),
features = c(1, -0.5, 0.3, 1.2),
time = NULL)
## Not run:
# aggregation won't work, but produces informative error message
aggregate(sento_measures,
time = list(W = c("equal_weight", "almon1")),
lexicons = list(LEX = c("LM_en")),
features = list(journals = c("notInHere", "wapo")))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.