Assembling an RShiny application

Our RShiny application will be able to do the following:

  • Search Twitter for a keyword/hashtag
  • Display the top 100 results
  • Show the sentiment for the top 100 tweets

Let us first load all the necessary libraries and authenticate into our Twitter account:

library(shiny)library(twitteR, quietly = TRUE)library(stringr)library(sentimentr, quietly = TRUE)library(dplyr, quietly = TRUE)consumer.key <- ""consumer.secret <- ""access.token <- ""token.secret <- ""setup_twitter_oauth(consumer.key, consumer.secret, access.token, token.secret)

Fill in your consumer.keys, secret, access.token, and token.secret.

Let us build the user interface part:

ui <- fluidPage(  navbarPage("TweetSenti",             tabPanel("Search Tweets" , textInput("search","search",value="#bladerunner") ...

Get R Data Analysis Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.