16.3 Download Data
- We will download tweets with ‘#auspol’; a popular hashtag used in Australia to talk about current affairs and socio-political issues
- Example here uses rtweet package to download data
- After setting up the API
- Create the token
search_tweets
can be used without creating the token, it will create a token using the default app for your Twitter account
library(rtweet)
<- create_token(app = "your_app_name", consumer_key = "your_consumer_key",
token consumer_secret = "your_consumer_secret", access_token = "your_access_token",
access_secret = "your_access_secret")
- Use the
search_tweets
function to download the data, convert to data frame and save
= search_tweets(q = "#auspol", n = 15000, type = "recent", include_rts = FALSE,
rt since = "2020-09-14")
= as.data.frame(rt)
rt2 saveRDS(rt2, file = "tweets_auspol.rds")