Learn R Programming

sentometrics (version 0.5.6)

sento_measures: One-way road towards a sentomeasures object

Description

Wrapper function which assembles calls to compute_sentiment and aggregate. Serves as the most direct way towards a panel of textual sentiment measures as a sentomeasures object.

Usage

sento_measures(sentocorpus, lexicons, ctr)

Arguments

sentocorpus

a sentocorpus object created with sento_corpus.

lexicons

a sentolexicons object created with sento_lexicons.

ctr

output from a ctr_agg call.

Value

A sentomeasures object, which is a list containing:

measures

a data.table with a "date" column and all textual sentiment measures as remaining columns.

features

a character vector of the different features.

lexicons

a character vector of the different lexicons used.

time

a character vector of the different time weighting schemes used.

by

a single character vector specifying the time interval of aggregation used.

stats

a data.frame with a series of elementary statistics (mean, standard deviation, maximum, minimum, and average correlation with all other measures) for each individual sentiment measure.

sentiment

the sentiment scores data.table with "date", "word_count" and lexicon--feature sentiment scores columns. The "date" column has the dates converted at the frequency for across-document aggregation. All zeros are replaced by NA if ctr$do.ignoreZeros = TRUE.

howDocs

a single character vector to remind how sentiment across documents was aggregated.

fill

a single character vector that specifies if and how missing dates have been added before aggregation across time was carried out.

do.ignoreZeros

a single character vector to remind if documents with a zero feature-sentiment score have been ignored in the within-document aggregation.

attribWeights

a list of document and time weights used in the attributions function. Serves further no direct purpose.

Details

As a general rule, neither the names of the features, lexicons or time weighting schemes may contain any `-' symbol.

See Also

compute_sentiment, aggregate

Examples

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

# construct a sentomeasures 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(howWithin = "counts",
               howDocs = "proportional",
               howTime = c("equal_weight", "linear", "almon"),
               by = "month",
               lag = 3,
               ordersAlm = 1:3,
               do.inverseAlm = TRUE)
sentomeasures <- sento_measures(corpusSample, l, ctr)
summary(sentomeasures)

# }

Run the code above in your browser using DataLab