Learn R Programming

sentometrics (version 0.2)

sento_measures: One-way road towards a sentomeasures object

Description

Wrapper function which assembles calls to compute_sentiment and perform_agg, and includes the input sentocorpus and computed sentiment scores in its output. 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

output from a setup_lexicons call.

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" and lexicon--feature sentiment scores columns. If ctr$do.ignoreZeros = TRUE, all zeros are replaces by NA.

howWithin

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

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 zero sentiment have been ignored in the within-document aggregation.

attribWeights

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

See Also

compute_sentiment, perform_agg

Examples

Run this code
# NOT RUN {
data("usnews")
data("lexicons")
data("valence")

# construct a sentomeasures object to start with
corpus <- sento_corpus(corpusdf = usnews)
corpusSample <- quanteda::corpus_sample(corpus, size = 750)
l <- setup_lexicons(lexicons[c("LM_eng", "HENRY_eng")], valence[["valence_eng"]])
ctr <- ctr_agg(howWithin = "tf-idf",
               howDocs = "proportional",
               howTime = c("equal_weight", "linear", "almon"),
               by = "month",
               lag = 3,
               ordersAlm = 1:3,
               do.inverseAlm = TRUE,
               do.normalizeAlm = TRUE)
sentomeasures <- sento_measures(corpusSample, l, ctr)
summary(sentomeasures)

# }

Run the code above in your browser using DataLab