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

那年仲夏 提交于 2019-12-06 09:14:11

问题


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


回答1:


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."




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/29333116/r-and-twitter-usertimeline-function-not-returning-the-number-of-tweets-reque

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!