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:

code that works

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归因
不隶属于 StackOverflow
scroll top