My data set has 4 columns which are station_name, station_lat, station_lng and count.This is the example of my data set.
stations <- data.frame(station = c("StreeterDr", "MichiganAve", "WellsSt"), lat = c(41.89228, 41.90096, 41.91213), lng = c(-87.61204, -87.62378, -87.63466), count = c(2300, 5678, 3452))
I want to plot these coordinates on maps. Referring previous post on this topic I tried this code. But it's not working.
install.packages(c("leaflet", "sp"))
library(leaflet)
library(leaflet)
lon <- stations$start_lng
lat <- stations$start_lat
df <- as.data.frame(cbind(lon,lat))
coordinates(df) <- ~lon+lat
leaflet(df) %>% addMarkers() %>% addTiles()