Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Created December 2, 2020 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadenbuie/33c350458305f4423f30c1274be63b34 to your computer and use it in GitHub Desktop.
Save gadenbuie/33c350458305f4423f30c1274be63b34 to your computer and use it in GitHub Desktop.
library(rtweet)
last_tweet_id <- "1333907891049402371"
lookup_thread <- function(status_id, tweets = NULL) {
tweet <- rtweet::lookup_tweets(status_id)
tweets <- dplyr::bind_rows(tweet, tweets)
if (is.na(tweet$reply_to_status_id)) {
return(tweets)
} else {
lookup_thread(tweet$reply_to_status_id, tweets)
}
}
# gather from last tweet to first tweet in the thread,
# following the trail of reply_to_status_id
thread <- lookup_thread(last_tweet_id)
# https://git.io/JITyy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment