We will leverage the twitteR package to extract tweets. Refer to https://cran.r-project.org/web/packages/twitteR/index.html to get more information about this package.
In order to use this package, you need a Twitter account. With the account, sign in to https://app.twitter.com and create an application. Use the consumer key, consumer secret key, access token, and access token security keys from that page to authenticate into Twitter.
Authorizing with keys into Twitter is done as follows:
library(twitteR, quietly = TRUE)
setup_twitter_oauth(consumer.key, consumer.secret, access.token, token.secret)
We are ready to extract some tweets.
We will retrieve only the English tweets using the searchTwitter function provided by the twitteR package:
tweet.results <- searchTwitter("@apple", n=1000,lang = "en")
tweet.df <- twListToDF(tweet.results) ...