I am trying to map latitude and longitude on a ggmap plot. I am able to get the map correctly from get_map. When I am using the geom_point, it is dropping all my rows and plotting nothing. I ended up having to import the latitude and longitude as character as it was dropping data with col_double()
I have tried to change the data type of my coordinates, first to as.numeric(latitude) and then as as.numeric(as.character(latitude))
Import the data
df2 <- read_csv(path2, col_types =cols(
Address = col_character(),
City = col_character(),
State = col_character(),
`Zip Code` = col_character(),
Latitude = col_character()
Longitude = col_character()
))
df2 <-
tibble(
Latitude = c(32.8, 40.6),
Longitude = c(-117, -122)
)
map <- get_map(location = "california", zoom=3)
ggmap(map) + geom_point(data = df2[df2$State=='California',], aes(x = as.numeric(Latitude), y = as.numeric(Longitude)), color="red", size = 5, shape = 21)
I would expect it to plot locations