I am trying to add labels at each point, particularly the row names. I am using the following code:
Clust <- factor(as.factor(XYClass_df_4326$Class))
sa_map7_plt <- OpenStreetMap::autoplot.OpenStreetMap(sa_map2) +
geom_point( data = XYClass_df_4326, aes(x = X, y = Y,color = Clust ), size = 2.5 ) +
geom_point( data = XYBord_df_4326, aes(x = X, y = Y), size = 0.5 ) +
# geom_text(label=rownames(XYClass_df_4326)) +
scale_colour_manual(breaks = c("1", "2", "3"),
values = c("red", "black", "blue")) +
xlab("Longitude (°E)") + ylab("Latitude (°S)" )
sa_map7_plt
I have commented the geom_text function, because when I use it I get the following error: Error: Aesthetics must be either length 1 or the same as the data (1): label
When I comment this function, I get the following graph: