我正在尝试从特定地理位置下载鸣叫进行分析。我要在表格中填充纬度和经度。 (我之前一直得到null)
我找到了此链接How to extract tweet geocode in twitteR package in R,并尝试使用该代码。
我首先收到此错误:“限制速率....阻塞一分钟并重试119次...”试图通过添加returnonRateLimit和sys.sleep进行修复,但现在我遇到了一个新错误:< / p>
Error in tw_from_response(out, ...) :
unused argument (retryonRateLimit = 200)
4.twInterfaceObj$doAPICall(cmd, params, "GET", ...)
3.doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
retryOnRateLimit,
...)
2.searchTwitter(searchString = searchtext, n = 1000, geocode =
coordinates$search.twitter.entry[i],
retryonRateLimit = 200)
1.twitter_lat_lon("food", 10, "100km")
我对R比较陌生,有人可以告诉我我的代码有什么问题吗?
twitter_lat_lon <- function(searchtext,locations,radius){
radius=radius
lat<-runif(n=locations, min=43.6266, max=43.8709)
long<-runif(n=locations, min=-79.752, max=-79.071)
#generate data fram with random longitude, latitude and chosen radius
coordinates<-as.data.frame(cbind(lat,long,radius))
coordinates$lat<-lat
coordinates$long<-long
#create a string of the lat, long, and radius for entry into searchTwitter()
for(i in 1:length(coordinates$lat)){
coordinates$search.twitter.entry[i]<-toString(c(coordinates$lat[i], coordinates$long[i],radius))
}
# take out spaces in the string
coordinates$search.twitter.entry<-gsub(" ","", coordinates$search.twitter.entry ,fixed=TRUE)
#Search twitter at each location, check how many tweets and put into dataframe
for(i in 1:length(coordinates$lat)){
coordinates$number.of.tweets[i]<-length(searchTwitter(searchString=searchtext,n=1000,geocode=coordinates$search.twitter.entry[i], retryonRateLimit = 200))
sys.sleep(30)}
}