Learn R Programming

SentimentAnalysis (version 1.1-0)

plotSentiment: Line plot with sentiment scores

Description

Simple line plot to visualize the evolvment of sentiment scores. This is especially helpful when studying a time series of sentiment scores.

Usage

plotSentiment(sentiment, x = NULL, cumsum = FALSE, xlab = "",
  ylab = "Sentiment")

Arguments

sentiment
data.frame or numeric vector with sentiment scores
x
Optional parameter with labels or time stamps on x-axis.
cumsum
Parameter deciding whether the cumulative sentiment is plotted (default: cumsum=FALSE).
xlab
Name of x-axis (default: empty string).
ylab
Name of y-axis (default: "Sentiment").

Value

Returns a plot of class ggplot

See Also

plotSentimentResponse and plot.SentimentDictionaryWeighted for further plotting options

Examples

Run this code
sentiment <- data.frame(Dictionary=runif(20))

plotSentiment(sentiment)
plotSentiment(sentiment, cumsum=TRUE)

# Change name of x-axis
plotSentiment(sentiment, xlab="Tone")

library(ggplot2)
# Extend plot with additional layout options
plotSentiment(sentiment) + ggtitle("Evolving sentiment")
plotSentiment(sentiment) + theme_void() 

Run the code above in your browser using DataLab