Reputation: 21
I'm plotting some points over a map using ggmap. This is the error message:
Removed 10 rows containing missing values (geom_point).
This is my code:
library(ggmaps)
library(maps)
library(DataComputing)
map <- get_map(location='san francisco', zoom=12, maptype = 'terrain', source = 'google', color = 'color')
ggmap(map) %>%
+ geom_point(aes(x=longitude, y=latitude, colour = as.numeric(total)), data=district_crimes) %>%
+ scale_color_gradient(low='beige', high='blue')
Proof that longitude and latitude are numeric.
How do get the points to plot? Thanks.
Upvotes: 1
Views: 697
Reputation: 24252
The suggestion of @timfaber is right. Longitude is placed on the x axis and latitude on the y axis, as you can see from the axes labels of the following plot:
ggmap(map)
Hence, the right way to plot points on your map is:
ggmap(map) +
geom_point(aes(x=latitude, y=longitude, colour = as.numeric(total)),
size=4, data=district_crimes) +
scale_color_gradient(low='blue', high='red')
Upvotes: 2