diff.sento_measures: Differencing of sentiment measures

Description Usage Arguments Value Author(s) Examples

View source: R/sentomeasures_methods.R

Description

Differences the sentiment measures from a sento_measures object.

Usage

1
2
## S3 method for class 'sento_measures'
diff(x, lag = 1, differences = 1, ...)

Arguments

x

a sento_measures object created using sento_measures.

lag

a numeric, see documentation for the generic diff.

differences

a numeric, see documentation for the generic diff.

...

not used.

Value

A modified sento_measures object, with the measures replaced by the differenced measures as well as updated statistics.

Author(s)

Samuel Borms

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

# first-order difference sentiment measures with a lag of two
diffed <- diff(sento_measures, lag = 2, differences = 1)

sentometrics documentation built on Aug. 18, 2021, 9:06 a.m.