Skip to contents

With a TAGS archive imported into R, pull_tweet_data() uses the rtweet package to query the Twitter API. Using rtweet requires Twitter API keys associated with an approved developer account. Fortunately, the rtweet vignette, Authentication, provides a thorough guide to obtaining Twitter API keys. Following these directions, you will run the rtweet::create_token() function, which saves your Twitter API keys to the .Renviron file. You can also edit this file directly using the usethis::edit_r_environ(scope='user') function.

Usage

pull_tweet_data(df, url_vector = NULL, id_vector = NULL, n = NULL)

Arguments

df

A dataframe of containing the column name 'status_url' (i.e., the hyperlink to specific statuses), such as that returned by read_tags()

url_vector

A vector of status URLs, such as as those contained in the 'status_url' column of a dataframe returned by tidytags::read_tags()

id_vector

A vector of statuses (i.e., ID numbers, such as those contained in the 'id_str' column of a dataframe returned by tidytags::read_tags()

n

The number of statuses to look up, by default the total number of tweet ID numbers available, but capped at 90,000 due to Twitter API limitations.

Value

A dataframe of statuses and full metadata from the Twitter API

Details

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

See also

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

Examples


if (FALSE) {

## Import data from a TAGS tracker:
example_tags_tracker <- "18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8"
tags_content <- read_tags(example_tags_tracker)

## Use any of three input parameters (TAGS dataframe, `status_url`
##   column, or `id_str` column)
pull_tweet_data(tags_content)
pull_tweet_data(url_vector = tags_content$status_url)
pull_tweet_data(id_vector = tags_content$id_str)

## Specifying the parameter `n` clarifies how many statuses to look up,
##   but the returned values may be less than `n` because some statuses
##   may have been deleted or made protected since the TAGS tracker
##   originally recorded them.
pull_tweet_data(tags_content, n = 10)

## Note that the following two examples will return the same thing:
pull_tweet_data(url_vector =
  "https://twitter.com/tweet__example/status/1176592704647716864")
pull_tweet_data(id_vector = "1176592704647716864")
}