[英]ggmap / ggplot error when plotting points on a ggmap: [arguments imply differing number of rows]
The following code works fine: 以下代码工作正常:
library(ggmap)
mp2 <- ggmap::get_map(location="South America", zoom = 4, source="google")
ggmap(mp2) +
geom_point(aes(c(-60), c(-1)), size=15) # plot one single point on map
generating this: 产生这个:
Though the following won't behave as expected for some reason: 虽然以下因某些原因不会出现预期的情况:
ggmap(mp2) +
geom_point(aes(c(-60, -65, -62), c(-1, -5, -10)))
giving me the following error: 给我以下错误:
Error in data.frame(x = c(-60, -65, -62), y = c(-1, -5, -10), PANEL = c(1L, :
arguments imply differing number of rows: 3, 4
this should work 这应该工作
df <- data.frame(lon=c(-60, -65, -62), lat = c(-1, -5, -10))
ggmap(mp2) +
geom_point(aes(x = lon, y = lat), size = 10, data = df)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.