I wanted to plot coordinates from a dataset onto a map, I used the code I found from Here. My code looked like this:
# creating a sample data.frame with your lat/lon points
lon <- c(known_long_lat$takeoff.longitude)
lat <- c(known_long_lat$takeoff.latitude)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4, maptype = "satellite", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8),
size = 5, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)`
When I run this code I get this error:
Error in if (lon < -180 || lon > 180) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In mean.default(df$lon) : argument is not numeric or logical: returning NA 2: In mean.default(df$lat) : argument is not numeric or logical: returning NA
I thought maybe it was because I had non-numeric data in the latitude and longitude columns but there doesn't seem to be.