使用我在网上找到的教程,我试图用ggplot2
按位置绘制推文(由R检索),但是当我尝试在控制台中运行代码时,会出现以下错误:
错误:提供给连续刻度的离散值
以下是代码:
library(twitteR)
library(ggplot2)
library(maps)
library(stringr)
library(igraph)
library(reshape2)
## Twitter authentication
consumer_key <- "XXX"
consumer_secret <- "XXX"
access_token <- "XXX"
access_secret <- "XXX"
setup_twitter_oauth(consumer_key, consumer_secret, access_token,
access_secret)
#Search Tweets
tweets2 = searchTwitter("Rio2016",lang="en",n=5000)
tweetsDF2 = twListToDF(tweets2)
tweetsDF2$longitude <- as.numeric(tweetsDF2$longitude)
tweetsDF2 <- tweetsDF2[!is.na(tweetsDF2$longitude),]
#Initialize map of Globe
tweetMap <- ggplot(map_data("world"))
#Create lines for countries, etc.
tweetMap <- tweetMap + geom_path(aes(x = long, y = lat, group = group), color = gray(2/3), lwd = 1/3)
#Add in our geo-tagged data
tweetMap <- tweetMap + geom_point(data=tweetsDF2,aes(x = longitude, y = latitude), color = "red", alpha = 1/2, size = 2)
tweetMap
似乎R并不认识从Twitter推出的Lat Lon数据。有什么建议吗?