的纬度和经度值我收集了一些Twitter的数据这样做:不能得到鸣叫
#connect to twitter API
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
#set radius and amount of requests
N=200 # tweets to request from each query
S=200 # radius in miles
lats=c(38.9,40.7)
lons=c(-77,-74)
roger=do.call(rbind,lapply(1:length(lats), function(i) searchTwitter('Roger+Federer',
lang="en",n=N,resultType="recent",
geocode=paste (lats[i],lons[i],paste0(S,"mi"),sep=","))))
这个我做了后:
rogerlat=sapply(roger, function(x) as.numeric(x$getLatitude()))
rogerlat=sapply(rogerlat, function(z) ifelse(length(z)==0,NA,z))
rogerlon=sapply(roger, function(x) as.numeric(x$getLongitude()))
rogerlon=sapply(rogerlon, function(z) ifelse(length(z)==0,NA,z))
data=as.data.frame(cbind(lat=rogerlat,lon=rogerlon))
现在我想获得所有的鸣叫有长和纬度值:
data=filter(data, !is.na(lat),!is.na(lon))
lonlat=select(data,lon,lat)
但是现在我只能得到NA值....任何想法在这里出了什么问题?
你可以'输入'一些'罗杰'数据框(匿名,如有必要)。我们还能如何确保Twitter甚至提供了一些经纬值? – dww