I'm trying to search for around 20,000 tweets using keywords that are currently trending on my timeline.
However, I am only getting about 88 tweets. These are trending keywords in the entire country and it is highly unlikely that there are only 88 tweets available.
Here is my code
library(rtweet)
sona_tweets <- search_tweets(
q = "SONA19 OR SONA2019 OR SONA",
n = 25000,
type = "popular",
include_rts = FALSE,
retryonratelimit = TRUE
)
When using rtweet::search_tweets()
, you should take note of a few limitations and type
argument.
First, search_tweets()
only returns data from the past 6-9 days. In addition, to return more than 18,000 statuses in a single call, you must set retryonlimit = TRUE
.
From the documentation, the type
argument is defined as:
Character string specifying which type of search results to return from Twitter's REST API. The current default is type = "recent", other valid types include type = "mixed" and type = "popular".
Therefore to get "everything" from the last 6-9 days, you'll want to use type = "mixed"
. This means you should change your code to this:
library(rtweet)
sona_tweets <- search_tweets(
q = "SONA19 OR SONA2019 OR SONA",
n = 25000,
type = "mixed",
include_rts = FALSE,
retryonratelimit = TRUE
)
and you should return your expected results.