Sheryl Zhang
Sheryl Zhang

Reputation: 11

Extracting Retweets with get_retweets Using 'rtweet'

I have collected a dataset of tweets that are original (not a retweet) but has been retweeted for at least once. For this dataset of 6,000 original tweets, I'm trying to collect 30 retweets for each of them by using the get_retweets function from the 'rtweet' package. From past experience, if the original tweet has not been retweeted for at least 30 times, it would just return however many retweets the original tweet has.

get_retweets(status_id, n = 100, parse = TRUE, token = NULL, ...)

My line of code looks like this:

> for (i in seq(nrow(morethan1RT))) {  
  if (i == 1) {  
    my_retweets = data.frame(get_retweets(morethan1RT$status_id[i], n = 1))  
  }  
  else {  
    my_retweets = rbind(my_retweets, get_retweets(morethan1RT$status_id[i], n = 1))  
  }  
}  

I first created a data frame (to store all the retweets) by using the first original tweet's status id to extract 0

This for loop worked at first, but now I only get around 900 retweets (or even less than 100) after running the entire loop. I wasn't sure what went wrong--since Twitter has a limit on how much tweets you can collect every 15 minutes, I tried waiting longer to run the loop; separate the 6,000 tweets into smaller batches; restarting r... None of them worked.

I would really appreciate it if someone could point me to the right direction. Thanks!

Upvotes: 1

Views: 948

Answers (1)

Ntx
Ntx

Reputation: 11

rtweet documentations says about get_retweets: "Returns a collection of the 100 most recent retweets of a given status. NOTE: Twitter’s API is currently limited to 100 or fewer retweeters."

Upvotes: 1

Related Questions