Learn R Programming

SentimentAnalysis (version 1.1-0)

convertToBinaryResponse: Convert continuous sentiment to direction

Description

This function converts continuous sentiment scores into a their corresponding binary sentiment class. As such, the result is a factor with two levels indicating positive and negative content. Neutral documents (with a sentiment score of 0) are counted as positive.

Usage

convertToBinaryResponse(sentiment)

Arguments

sentiment
Vector, matrix or data.frame with sentiment scores.

Value

If a vector is supplied, it returns a factor with two levels representing positive and negative content. Otherwise, it returns a data.frame with the corresponding columns being exchanged.

Details

If a matrix or data.frame is provided, this routine does not touch all columns. In fact, it scans for those where the colum name starts with "Sentiment" and changes these columns only. Hence, colums with pure negativity, positivity or ratios or word counts are ignored.

See Also

convertToDirection

Examples

Run this code
sentiment <- c(-1, -0.5, +1, 0.6, 0)
convertToBinaryResponse(sentiment)
convertToDirection(sentiment)

df <- data.frame(No=1:5, Sentiment=sentiment)
df
convertToBinaryResponse(df)
convertToDirection(df)

Run the code above in your browser using DataLab