I manually entered latitude and longitude in my dataset in csv format and imported the dataset to R. I am trying convert the variable lat
and lng
into coordinates so that I can use tmap
or geom_sf
to plot it as a map in R. But I am not able to do so. I used the following code to convert the variables lat
and lng
to coordinates and it did not work. I am attaching the image of my dataset here. can someone help me? I want to plot variable lat
and lng
on a map.
cov2 <- st_as_sf(co1, coords = c('lng', 'lat'))
ggplot(co1) +
geom_sf()
coordinates(co1)<-6:7