plot.sento_measures {sentometrics} | R Documentation |
Plot sentiment measures
Description
Plotting method that shows all sentiment measures from the provided sento_measures
object in one plot, or the average along one of the lexicons, features and time weighting dimensions.
Usage
## S3 method for class 'sento_measures'
plot(x, group = "all", ...)
Arguments
x |
a |
group |
a value from |
... |
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"
.
Author(s)
Samuel Borms
Examples
# construct a sento_measures object to start with
corpus <- sento_corpus(corpusdf = sentometrics::usnews)
corpusSample <- quanteda::corpus_sample(corpus, size = 500)
l <- sento_lexicons(sentometrics::list_lexicons[c("LM_en")],
sentometrics::list_valence_shifters[["en"]])
ctr <- ctr_agg(howTime = c("equal_weight", "linear"), by = "month", lag = 3)
sm <- sento_measures(corpusSample, l, ctr)
# plot sentiment measures
plot(sm, "features")
## Not run:
# adjust appearance of plot
library("ggplot2")
p <- plot(sm)
p <- p +
scale_x_date(name = "year", date_labels = "%Y") +
scale_y_continuous(name = "newName")
p
## End(Not run)