Sentiment Analysis Using R-Programming
Sentiment Analysis is the process of computationally identifying and categorizing opinions expressed in a piece of text, especially in order to determine whether the writer’s attitude towards a particular topic, product, etc., is positive, negative, or neutral.
In this article we will create a very simple sentiment analysis program using the R programming language and the RSentiment package. You will need R & RStudio. If you do not have them already downloaded then you can watch the video below that will show you how to install them step by step on Windows, or you can read the my article here on medium called “Install R and RStudio On Windows”.
Open RStudio, which is where we are going to create our R sentiment analysis program.
Install the package called “RSentiment”
Load the package called “RSentiment”
Run the following code
The RSentiment package allows us to use a few functions that takes in a vector of text and outputs the sentiment or number of sentiments or number values of the sentiment.
- calculate_total_presence_sentiment(c(“This is good”,”This is bad”))
This function loads text and calculates number of sentences which are positive, negative, very positive,
very negative, neutral and sarcasm.
2. calculate_score(c(“This is good”, “that is bad”, “what is this”))
This function loads text and calculates sentiment of each sentence. It classifies sentences into 6
categories: Positive, Negative, Very Positive, Very Negative Sarcasm and Neutral.
3. calculate_sentiment(c(“that is very good”, “this is bad”))
This function loads text and calculates the number corresponding to the sentiment.
library(RSentiment)calculate_total_presence_sentiment(c("This is a good text", "This is a bad text", "This is a really bad text", "This is horrible"))calculate_sentiment(c("This is a good text", "This is a bad text", "This is a really bad text", "This is horrible"))calculate_score(c("This is a good text", "This is a bad text", "This is a really bad text", "This is horrible"))
Contribute to R-Programs development by creating an account on GitHub.
You are done those functions will return the sentiment of the input text, so now you can go and figure out the sentiment of any author !
Thanks for reading this article I hope its helpful to you all ! Keep up the learning, and if you would like more computer science, programming and algorithm analysis videos please visit and subscribe to my YouTube channels (randerson112358 & compsci112358 )
Check Out the following for content / videos on Computer Science, Algorithm Analysis, Programming and Logic:
Video Tutorials on Recurrence Relation:
Video Tutorial on Algorithm Analysis: