I am trying to plot points on a map using R and plotGoogleMaps. I have a dataframe that I am attempting to use but I can not figure out how to do it.
My code is:
df <- data.frame(dbGetQuery(con, paste('select * from googlemaps')))
An example of the out to this is:
T1141 LAT LNG
1 A/BCD 51.48503 -0.062313
2 B/CDE 51.56495 -0.078709
3 C/DEF 51.54829 -0.0469517
The next code I use is this:
coordinates(df) <- ~LAT+LNG
But this gives me the following error:
Error in .checkNumericCoerce2double(obj) :
cannot retrieve coordinates from non-numeric elements
What am I doing wrong here?
EDIT:
I tried checking the mode of the column as suggested in the comment and this was the result:
coordinates(df) <- ~LAT+LNG
Error in .checkNumericCoerce2double(obj) :
cannot retrieve coordinates from non-numeric elements
mode(df$LAT)
[1] "numeric"
mode(df$LNG)
[1] "numeric"