Learn R Programming

SentimentAnalysis (version 1.3-4)

plotSentimentResponse: Scatterplot with trend line between sentiment and response

Description

Generates a scatterplot where points pairs of sentiment and the response variable. In addition, the plot addas a trend line in the form of a generalized additive model (GAM). Other smoothing variables are possible based on geom_smooth. This functions is helpful for visualization the relationship between computed sentiment scores and the gold standard.

Usage

plotSentimentResponse(
  sentiment,
  response,
  smoothing = "gam",
  xlab = "Sentiment",
  ylab = "Response"
)

Value

Returns a plot of class ggplot

Arguments

sentiment

data.frame with sentiment scores

response

Vector with response variables of the same length

smoothing

Smoothing functionality. Default is smoothing="gam" to utilize a generalized additive model (GAM). Other options can be e.g. a linear trend line (smoothing="lm"); see geom_smooth for a full list of options.

xlab

Description on x-axis (default: "Sentiment").

ylab

Description on y-axis (default: "Sentiment").

See Also

plotSentiment and plot.SentimentDictionaryWeighted for further plotting options

Examples

Run this code
sentiment <- data.frame(Dictionary=runif(10))
response <- sentiment[[1]] + rnorm(10)

plotSentimentResponse(sentiment, response)

# Change x-axis
plotSentimentResponse(sentiment, response, xlab="Tone")

library(ggplot2)
# Extend plot with additional layout options
plotSentimentResponse(sentiment, response) + ggtitle("Scatterplot")
plotSentimentResponse(sentiment, response) + theme_void() 

Run the code above in your browser using DataLab