Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## issues:
- ## -only gets replies within last ~7 days to the post due to public REST API limits
- ## -counts don't necessarily align with total replies via browser, perhaps due to private accounts (?)
- get_replies <- function(tweetid){
- # get status information for given tweet
- t <- rtweet::lookup_statuses(statuses = tweetid)
- # use search API to find all tweets directed to the poster
- # and keep only replied to that status
- z <- rtweet::search_tweets(q = paste0("to:",t$screen_name),
- sinceID = tweetid,
- n = 3200)
- # keep only replies to tweetid status
- z <- subset(z, in_reply_to_status_status_id == tweetid)
- # combine original tweet and replies
- z <- rbind(t, z)
- # return dataframe
- return(z)
- }
- tweetid <- "998970022474199041"
- z <- get_replies(tweetid)
- # to get multiple; install purrr if you do not have it
- tweetid <- c("998662565222895618","998602734386458626")
- z <- purrr::map_df(tweetid, get_replies)
Add Comment
Please, Sign In to add comment