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

Image for post
Image for post

Install the package called “RSentiment”

install.packages(“RSentiment”)
Image for post
Image for post

Load the package called “RSentiment”

library(“RSentiment”)

Run the following code

  1. 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 )

Image for post
Image for post

Check Out the following for content / videos on Computer Science, Algorithm Analysis, Programming and Logic:

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:

Image for post
Image for post

Computer Science Website:

Image for post
Image for post

Udemy Videos on Algortithm Analysis:

Image for post
Image for post

Resources:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store