Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 推特包中的Lat-Lon产生NA_R_Twitter - Fatal编程技术网

R 推特包中的Lat-Lon产生NA

R 推特包中的Lat-Lon产生NA,r,twitter,R,Twitter,我试图通过这个包获得lat+lon,但是得到的数据帧的lat/lon列都是NA tweets<-searchTwitter('cats',n=100) tweets<-do.call("rbind",lapply(tweets,as.data.frame)) tweets看起来lat/lon不适用于tweets 我可以从撰写推文的用户那里获得位置信息。TwitteR固有的功能是做到这一点: a<-getUser("eastandwestwind") a$location [1

我试图通过这个包获得lat+lon,但是得到的数据帧的lat/lon列都是NA

tweets<-searchTwitter('cats',n=100)
tweets<-do.call("rbind",lapply(tweets,as.data.frame))

tweets看起来lat/lon不适用于tweets

我可以从撰写推文的用户那里获得位置信息。TwitteR固有的功能是做到这一点:

a<-getUser("eastandwestwind")
a$location
[1] "Boston, MA"

几乎没有推文附有位置。几年前,当我在tweet上做分析时,我看到的数据集不到10%。是的,你说得对。现在做一些变通,从实际用户而不是tweet中提取位置,然后根据gdata进行解析以找到lat-lon。
getLocation<-function(x){
    y<-getUser(x)
    return(y$location)
}

locations <- lapply(tweets$screenName, function(x) getLocation(x))
tweets$city<-locations
tweets<-data.frame(lapply(tweets, as.character), stringsAsFactors=FALSE)