get_upstream_tweets: Collect upstream statuses and add to dataset

View source: R/get-upstream-tweets.R

get_upstream_tweetsR Documentation

Collect upstream statuses and add to dataset

Description

Because the Twitter API offers a in_reply_to_status_id_str column, it is possible to iteratively reconstruct reply threads in an upstream direction, that is, retrieving statuses composed earlier than replies in the dataset. The get_upstream_tweets() function collects upstream replies not previously found in the dataset. Keep in mind that there is no way to predict how far upstream you can trace back a reply thread, so running get_upstream_tweets() could take a while and potentially hit the Twitter API rate limit of 90,000 statuses in a 15-minute period.

Usage

get_upstream_tweets(df)

Arguments

df

A dataframe of statuses and full metadata from the Twitter API as returned by pull_tweet_data()

Details

This function requires authentication; please see vignette("setup", package = "tidytags")

Value

A new, expanded dataframe which includes any retrievable upstream replies

See Also

Read more about rtweet authentication setup at vignette("auth", package = "rtweet")

Examples



example_url <- "18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8"
tags_content <- read_tags(example_url)

if (rtweet::auth_has_default()) {
  tweets_data <- lookup_many_tweets(tags_content)
  more_replies_df <- get_upstream_tweets(tweets_data)
  more_replies_df
}



bretsw/rtags documentation built on Feb. 4, 2024, 6:20 a.m.