Learn R Programming

sentometrics (version 0.7.5)

sento_measures: One-way road towards a sento_measures 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 sento_measures object.

Usage

sento_measures(sento_corpus, lexicons, ctr)

Arguments

sento_corpus

a sento_corpus object created with sento_corpus.

lexicons

a sentolexicons object created with sento_lexicons.

ctr

output from a ctr_agg call.

Value

A sento_measures 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.

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 document-level 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$docs$weightingParam$do.ignoreZeros = TRUE.

attribWeights

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

ctr

a list encapsulating the control parameters.

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, measures_update

Examples

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

# }

Run the code above in your browser using DataLab