错误:无法找到函数" filterStream",有关此错误原因的任何建议?

时间:2016-07-04 11:55:30

标签: r twitter

我正在尝试运行下面的代码,我在CRAN软件包 streamR link here的示例中找到了,但在运行时遇到错误,有人可以告诉我为什么这样做错误,我该如何解决这个问题。谢谢你的帮助。

## Not run:
## An example of an authenticated request using the ROAuth package,
## where consumerkey and consumer secret are fictitious.
## You can obtain your own at dev.twitter.com
library(ROAuth)
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "http://api.twitter.com/oauth/authorize"
consumerKey <- "xxxxxxxxxxxxxx"
consumerSecret <- "xxxyyyyyyyyyyyzzzzzzz1111111122222222"
my_oauth <- OAuthFactory$new(consumerKey=consumerKey, consumerSecret=consumerSecret, requestURL=requestURL, accessURL=accessURL, authURL=authURL)
my_oauth$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))
filterStream( file="tweets_rstats.json",track="rstats", timeout=3600, oauth=my_oauth )
## capture 10 tweets mentioning the "Rstats" hashtag
filterStream( file.name="tweets_rstats.json", track="rstats", tweets=10, oauth=my_oauth )
## capture tweets published by Twitter's official account
filterStream( file.name="tweets_twitter.json", follow="783214", timeout=600, oauth=my_oauth )
## capture tweets sent from New York City in Spanish only, and saving as an object in memory
tweets <- filterStream( file.name="", language="es",locations=c(-74,40,-73,41), timeout=600, oauth=my_oauth )
## capture tweets mentioning the "rstats" hashtag or sent from New York City
filterStream( file="tweets_rstats.json", track="rstats",locations=c(-74,40,-73,41), timeout=600, oauth=my_oauth )
## End(Not run)

2 个答案:

答案 0 :(得分:0)

可能是“my_oauth $ handshake”之后的第一个filterStream

filterStream( file="tweets_rstats.json",track="rstats", timeout=3600, oauth=my_oauth )

应该是:

filterStream( file.name="tweets_rstats.json",track="rstats", timeout=3600, oauth=my_oauth )

答案 1 :(得分:0)

您是否在Twitter Apps注册了Twitter应用程序? 如果是,您是否在http://127.0.0.1:1410上设置了回调网址?

你得到了什么类型的错误?我正在考虑身份验证过程中的一些问题, filterStream 需要通过 my_oauth 来获取身份验证并启动下载。