Simple program in R to fetch tweets from any twitter handle

##twitteR package gets the tweets 
library("twitteR")
## ROAuth helps in establishing connection with twitter and other social media sites
library("ROAuth")

## Set Options
options(httr_oauth_cache=T)

Set API Keys

To access data from Twitter we need to get API keys which can be generated by creating a new app at https://apps.twitter.com/

# Set API Keys
#api_key <- "******"
#api_secret <- "******"
#access_token <- "******"
#access_token_secret <- "*****"

setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)
## [1] "Using direct authentication"
# Set search string
search.string <- "@MakeMyTripIndia"

# Get 5 tweets on the MMT handle
tweets <- searchTwitter(search.string, n=5, lang="en", since=NULL, until=NULL, retryOnRateLimit=10)

## Let's check the data in the tweets object
head(tweets)
## [[1]]
## [1] "TusharAvinash: RT @avinash2584: @makemytripcare @MakeMyTripIndia Booked and made full payment on 8th but still waiting for flight tickets, Hotel &amp; other v<U+0085>"
## 
## [[2]]
## [1] "greeshma15: @makemytrip My team is trying to get an issue resolved for 4 days and its all in vain. Pathetic customer care! All<U+0085> https://t.co/1j9IkX1Zf8"
## 
## [[3]]
## [1] "avinash2584: @makemytripcare @MakeMyTripIndia It<U+0092>s international holiday package"
## 
## [[4]]
## [1] "avinash2584: @makemytripcare @MakeMyTripIndia Booked and made full payment on 8th but still waiting for flight tickets, Hotel &amp;<U+0085> https://t.co/d4Uzl5Lqzy"
## 
## [[5]]
## [1] "Yasmine70272991: RT @AnkushSona1986: @MakeMyTrip_Pub @MakeMyTripIndia  after security deposit hotel allow to check in this type service provide to customer<U+0085>"
## Get 100 tweets where this word has been used
ut <- userTimeline('MakeMyTripIndia', n=100)

mmt_df <- do.call("rbind", lapply(ut, as.data.frame))

## Let's check the column names in the usertimeline data frame
names(mmt_df)
##  [1] "text"          "favorited"     "favoriteCount" "replyToSN"    
##  [5] "created"       "truncated"     "replyToSID"    "id"           
##  [9] "replyToUID"    "statusSource"  "screenName"    "retweetCount" 
## [13] "isRetweet"     "retweeted"     "longitude"     "latitude"
## Let's view the first 10 rows
head(mmt_df, n =10)