Easy Sentiment Analysis With R
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
Open RStudio, which is where we are going to create our R sentiment analysis program.

Install the package called “RSentiment”
install.packages(“RSentiment”)

Load the package called “RSentiment”
library(“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”))
Description:
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”))
Description:
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”))
Description:
This function loads text and calculates the number corresponding to the sentiment.
#install.packages("RSentiment")
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"))
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:
YouTube Channel:
randerson112358: https://www.youtube.com/channel/UCaV_0qp2NZd319K4_K8Z5SQ
compsci112358:
https://www.youtube.com/channel/UCbmb5IoBtHZTpYZCDBOC1CA
Website:
http://everythingcomputerscience.com/
Video Tutorials on Recurrence Relation:
https://www.udemy.com/recurrence-relation-made-easy/
Video Tutorial on Algorithm Analysis:
https://www.udemy.com/algorithm-analysis/
Twitter:
https://twitter.com/CsEverything
YouTube Channel:

Computer Science Website:

Udemy Videos on Algortithm Analysis:
