[英]Points in a map with qmplot
I have to plot some points in a map. 我必须在地图中绘制一些点。 I want to use
qmplot
, because it seems simple and effective. 我想使用
qmplot
,因为它看似简单有效。
I have followed this tutorial , but I cannot get it to work: 我已经按照本教程 ,但我不能让它工作:
# Libraries
install.packages("maps")
install.packages("ggmap")
library(maps)
library(ggmap)
# Loading European map:
map <- get_map(location = 'Europe', zoom = 4)
ggmap(map)
# Madrid coordinates
df <- data.frame(lon=c(-3.757324), lat=c(40.441721))
# Plotting the point
qmplot(df$lon, df$lat)
qmplot(df$lon, df$lat, data = df)
I get this error: 我收到此错误:
Error in `[.data.frame`(data, , deparse(substitute(x))) :
`[.data.frame`(data ,, deparse(substitute(x)))出错:
undefined columns selected选择了未定义的列
If you want to draw your points over the map of Europe you get in the first step, this is what you can do instead: 如果你想在第一步中获得欧洲地图上的积分,那么你就可以做到这一点:
# Libraries
library(maps)
library(ggmap)
# Loading European map:
map <- get_map(location = 'Europe', zoom = 4)
# Madrid coordinates
df <- data.frame(lon=c(-3.757324), lat=c(40.441721))
ggmap(map) + geom_point(data = df, aes(x = lon, y = lat))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.