I'm trying to download tweets using twitteR package in R. I have a list of twitter users and I want to download their tweets. I keep getting the error
Error in .self$twFromJSON(out) :
Error: Rate limit exceeded. Clients may not make more than 150 requests per hour.
How can I slow down the request so it can keep downloading within the limits and without interruption? Below is a sample code.
# Load package
library(twitteR)
# Read list of users from file
users <- read.table('listOfTwitterUsers.txt')
# Pause for 10 sec
sleepTime = 10
for (user in users){
# Download latest 2000 tweets from the user's timeline
tweets <- userTimeline(user, 2000)
# Extract tweets
tweets <- unlist( lapply(tweets, function(t) t$getText() ) )
# Save tweets to file
write.csv(tweets, file=paste("Downloads/", user, ".csv", sep=""), row.names=F)
Sys.sleep(sleepTime)
}