Skip to contents

Starting with a dataframe of Twitter data imported to R with read_tags() and additional metadata retrieved by pull_tweet_data(), filter_by_tweet_type() processes the statuses by calling process_tweets() and then removes any statuses that are not of the requested type (e.g., replies, retweets, and quote tweets). filter_by_tweet_type() is a useful function in itself, but it is also used in create_edgelist().


filter_by_tweet_type(df, type)



A dataframe returned by pull_tweet_data()


The specific kind of statuses that will be kept in the dataset after filtering the rest. Choices for typeinclude "reply", "retweet", "quote", and "original".


A dataframe of processed statuses and fewer rows that the input dataframe. Only the statuses of the specified type will remain.


# \donttest{
example_url <- "18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8"
tags_content <- read_tags(example_url)
#>  Reading from "#aect19 tweet collector".
#>  Range ''Archive''.

if (rtweet::auth_has_default()) {
  tweets_data <- lookup_many_tweets(tags_content)
  only_replies <- filter_by_tweet_type(tweets_data, "reply")
  only_retweets <- filter_by_tweet_type(tweets_data, "retweet")
  only_quote_tweets <- filter_by_tweet_type(tweets_data, "quote")
  only_originals <- filter_by_tweet_type(tweets_data, "original")
# }