Learn R Programming

sentometrics (version 0.5.6)

plot.sentomeasures: Plot sentiment measures

Description

Plotting method that shows all sentiment measures from the provided sentomeasures object in one plot, or the average along one of the lexicons, features and time weighting dimensions. We suggest to make use of a measures_xyz function when you want to plot only a subset of the sentiment measures.

Usage

# S3 method for sentomeasures
plot(x, group = "all", ...)

Arguments

x

a sentomeasures object created using sento_measures.

group

a value from c("lexicons", "features", "time", "all"). The first three choices display the average of all measures from the same group, in a different color. The choice "all" displays every single sentiment measure in a separate color, but this may look visually overwhelming very fast, and can be quite slow.

...

not used.

Value

Returns a simple ggplot object, which can be added onto (or to alter its default elements) by using the + operator (see example). By default, a legend is positioned at the top if there are at maximum twelve line graphs plotted and group is different from "all".

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")], list_valence_shifters[["en"]])
ctr <- ctr_agg(howTime = c("equal_weight", "linear"), by = "year", lag = 3)
sentomeasures <- sento_measures(corpusSample, l, ctr)

# plot sentiment measures
plot(sentomeasures, group = "features")

# }
# NOT RUN {
# adjust appearance of plot
p <- plot(sentomeasures)
p <- p +
  scale_x_date(name = "month-year") +
  scale_y_continuous(name = "newName")
p
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab