r - R 中 streamR 和 twitteR 包收到的推文差异

标签 r twitter

我正在尝试根据 Twitter 中的特定词检索推文。我在 R 中同时使用了 twitteR 和 streamR 包。

为了使用 twitteR 访问推文,我使用 searchTwitter("love", n=50) 而当我使用 streamR 包时,我使用 filterStream("tweets.json", track = c( "love"), timeout = 30, oauth = my_oauth)

然而,对于我尝试过的几乎所有搜索词,searchTwitter 都会返回更多推文,而 filterStream 无法获得那么多。

可能是什么原因?

最佳答案

您的 timeout = 30 选项很可能是这里的罪魁祸首。 filterStream()timeout 选项中指定的持续时间内访问 Twitter 流 API。来自 searchR documentation 超时:

numeric, maximum length of time (in seconds) of connection to stream. The connection will be automatically closed after this period. For example, setting timeout to 10800 will keep the connection open for 3 hours. The default is 0, which will keep the connection open permanently

这意味着带有 timeout = 30 选项的 filterStream 会监听 Twitter 流 30 秒。

另一方面,

searchTwitter() 搜索 API 中可用的 Twitter 历史记录 (6-9 days),直到达到 n=50 中指定的最大推文数量> 选项。所以这应该会产生 50 条推文。

streamRtwitteR 包用于不同的事情:http://pablobarbera.com/blog/archives/1.html如果要访问流,请使用 streamR,如果要访问 Twitter 历史记录,请使用 twitteR 包。两个包相互补充。

关于r - R 中 streamR 和 twitteR 包收到的推文差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30056157/

相关文章:

ios - 如何从 iOS 中的 Twitter 时间线对象获取大尺寸的用户个人资料图像

r - Tidyverse 解决方案,用于对多列产品进行行式求和

r - 如何在一个函数中使用多个代码在 R 中应用 "sapply"?

java - 如何从 'Twitter4J' 中的用户那里获取电子邮件地址?

twitter - 如何获取其他 Twitter 用户的提及?

python - 如何使用 python 保存乌尔都语推文并保存在 csv 文件中

r - 计算连续数字的运行平均值

在 R 中使用 NA 重新编码变量

r - 更改 read.table 用于确定 R 中列数的行数

twitter - 为什么 Twitter 不使用自己的 Bootstrap?