R and twitteR - userTimeline() function not returning the number of tweets requested

3.8k views Asked by At

Why can't I get the number of tweets I request when I use the userTimeline() function in the twitteR package ? I now the limit request for a user timeline is 3200 tweets but I just get about 10% of that...

Here are two examples :

In this example 'googledevs' account has only 2,000 tweets so I did ask for 1000 tweets and I still only got 106...

> library(twitteR)
> load('OAuth.RData')
> test <- userTimeline(user = 'googledevs', n=1000)
> length(test)
[1] 106

In this example 'FiveThirtyEight' has 5622 tweets. So I asked for 3200 and only got 317...

> library(twitteR)
> load('OAuth.RData')
> test2 <- userTimeline(user = 'FiveThirtyEight', n=3200)
> length(test2)
[1] 317

Can someone help me fix this ? Thank you

4

There are 4 answers

1
chatwon On BEST ANSWER

The Twitter API will only return tweets from the past week or so. See the documentation.

"The Search API is not complete index of all Tweets, but instead an index of recent Tweets. At the moment that index includes between 6-9 days of Tweets."

0
Shaila On

You need to include the includeRts=TRUE argument in your userTimeline call. This will return the minimum of 3200 posts and the total posts on the user's timeline.

0
Phill On

I believe the problem is that while it is only retrieving a certain number of tweets it is going through the maximum number you set. It includes retweets and replies. If you set to true the include replies and retweets options you should retrieve the total number of tweets you set. A nice workaround this limit is "making" time windows using the tweets ID and the sinceID and maxID options.

0
Shaila On

You need to include the includeRts=TRUE argument in your userTimeline call. This should give you the max of the number of tweets on the user's timeline and 3200.