compareToResponse {SentimentAnalysis} | R Documentation |
Compare sentiment values to existing response variable
Description
This function compares the calculated sentiment values with an external response variable. Examples of such an exogenous response are stock market movements or IMDb move rating. Both usually reflect a "true" value that the sentiment should match.
Usage
compareToResponse(sentiment, response)
## S3 method for class 'logical'
compareToResponse(sentiment, response)
## S3 method for class 'factor'
compareToResponse(sentiment, response)
## S3 method for class 'integer'
compareToResponse(sentiment, response)
## S3 method for class 'data.frame'
compareToResponse(sentiment, response)
## S3 method for class 'numeric'
compareToResponse(sentiment, response)
Arguments
sentiment |
Matrix with sentiment scores for each document across several sentiment rules |
response |
Vector with "true" response. This vector can either be of a continuous numeric or binary values. In case of the latter, FALSE is matched to a negative sentiment value, while TRUE is matched to a non-negative one. |
Value
Matrix with different performance metrics for all given sentiment rules
Examples
sentiment <- matrix(c(5.5, 2.9, 0.9, -1),
dimnames=list(c("A", "B", "C", "D"), c("Sentiment")))
# continuous numeric response variable
response <- c(5, 3, 1, -1)
compareToResponse(sentiment, response)
# binary response variable
response <- c(TRUE, TRUE, FALSE, FALSE)
compareToResponse(sentiment, response)
[Package SentimentAnalysis version 1.3-5 Index]