I am doing a basic Twitter sentiment analysis in RStudio: I already have a Twitter developer account.
Below is the code for getting the tweets:
title: "Twitter" output: html_document
knitr::opts_chunk$set(echo = TRUE)
library(rtweet) # Twitter package
# locations for analysis
mex_loc <- c(mexico_city = "19.43,-99.13,50mi",
guadalajara = "20.67,-103.35,50mi",
monterrey = "25.67,-100.3,50mi",
toluca = "19.28,-99.66,50mi")
# extract tweets
myquery <- "add my query here"
mytweets <- list()
# To use app based authentication
auth <- rtweet_app()
for (i in 1:4) {
mytweets[[i]] <- search_tweets(q = myquery,
n = 18000,
lang = "es",
geocode = mex_loc[i],
until = '2023-03-22' ,
include_rts = FALSE,
retryonratelimit = FALSE)
}
tweet_dt_retail <- data.table::rbindlist(mytweets, use.names=TRUE )
However whe I extract the tweets I get this error:
![Error when extract tweets] (https://i.stack.imgur.com/haA9R.png)
I would appreciate your help,
Javier