I am working with ggmap
. the goal is to plot coordinate points on the map and label the points with their names. I have data frame with name, longitude and latitude.
The data looks like:
df <- structure(list(Station.Area = c("Balbriggan", "Blanchardstown", "Dolphins Barn", "Donnybrook", "Dun Laoghaire", "Finglas"), Latitude = c(53.608319, 53.386813, 53.333532, 53.319259, 53.294396, 53.390325), Longitude = c(-6.18208, -6.377197, -6.29146, -6.232017, -6.133867, -6.298401)), .Names =c("Station.Area","Latitude", "Longitude"), row.names = c(NA, 6L), class = "data.frame")
The code I wrote is as below:
library(ggmap) library(ggplot2) dub_map <- get_map(location = "Dublin", zoom = "auto", scale="auto", crop = TRUE, maptype = "hybrid") ggmap(dub_map) +` geom_point(data = df, aes(x = Longitude, y = Latitude, fill = "green", alpha =` `0.8, size = 5, shape = 21)) +` guides(fill=FALSE, alpha=FALSE, size=FALSE)+ geom_text(label=df$Station.Area)+ scale_shape_identity()
But i am getting
Error: Aesthetics must be either length 1 or the same as the data (4): label
I have tried to put various aesthetics in geom_text
like size,color,x & Y but it still gives out same error.
Am i doing it correctly for my goal? Please help.
Getting this without geom_text now I just want to label the points