Everytime you release a product or service you want to receive feedback from users so you know what they like and what they don’t. Sentiment Analysis can help you. I will show you how to create a simple application in R and Shiny to perform Twitter Sentiment Analysis in real-time. I use RStudio.

We will be able to see if they liked our products or not. Also, we will create a wordcloud to find out why they liked it and why not.

First, I will create a Shiny Project. To learn how to create a Shiny apps you might read this tutorial by Teja Kodali and another tutorial by Aaron Gowins.

Then, in the ui.R file, I put this code:

shinyUI(fluidPage( titlePanel("Sentiment Analysis"), #Title textOutput("currentTime"), #Here, I show a real time clock h4("Tweets:"), #Sidebar title sidebarLayout( sidebarPanel( dataTableOutput('tweets_table') #Here I show the users and the sentiment ),

Show a plot of the generated distribution:

mainPanel( plotOutput("distPlot"), #Here I will show the bars graph sidebarPanel( plotOutput("positive_wordcloud") #Cloud for positive words ), sidebarPanel( plotOutput("negative_wordcloud") #Cloud for negative words ), sidebarPanel( plotOutput("neutral_wordcloud") #Cloud for neutral words )))))

Here, I will show a title, the current time, a table with Twitter user name, a bar graph and wordclouds. Also you have to put your consumer key and secret (replace xxxxxxxxxx). You will have to create and application in Twitter Developers site and then extract this info.

Now, I will create the server side: