This vignette provides a quick tour of the R package rtweet: Collecting Twitter Data.

Search tweets

Search for up to 18,000 (non-retweeted) tweets containing the rstats hashtag.

Quickly visualize frequency of tweets over time using ts_plot().

Twitter rate limits cap the number of search results returned to 18,000 every 15 minutes. To request more than that, simply set retryonratelimit = TRUE and rtweet will wait for rate limit resets for you.

Search by geo-location—for example, find 10,000 tweets in the English language sent from the United States.

Stream tweets

Randomly sample (approximately 1%) from the live stream of all tweets.

Stream all geo enabled tweets from London for 60 seconds.

Stream all tweets mentioning realDonaldTrump or Trump for a week.

Get friends

Retrieve a list of all the accounts a user follows.

Get favorites

Get the 3,000 most recently favorited statuses by JK Rowling.

jkr <- get_favorites("jk_rowling", n = 3000)

Search users

Search for 1,000 users with the rstats hashtag in their profile bios.

Posting statuses

post_tweet("my first rtweet #rstats")

Following users