WhatsApp Chat Sentiment Analysis in R

Extract Latest Tweets Using Keywords

Objective: Extract latest tweets about SpiderMan from Twitter world.

Step 1: Install and Load required package

>install.packages("twitteR")
>library(twitteR)

Step 2: Set up and Authorise Twitter OAuth

Get access your API and ACCESS Token by following this LINK.

>api_key <- "YOUR API KEY"
>api_secret <- "YOUR API SECRET"
>access_token <- "YOUR ACCESS TOKEN"
>access_token_secret <- "YOUR TOKEN SECRET"

>setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)

Step 3: Extract tweets using searchTwitter function

>tweets<-searchTwitter("spiderman",n=200,lang="en")
>view(tweets)

Output:

Step 4: Turn tweets into a dataframe

>Tweets_df<- do.call("rbind", lapply(tweets, as.data.frame))
>view(Tweets_df)

Output:



Write to us at info@planetanalytics.in





Instagram Post You May Like: