Ho to make markers have different colors based on specific variable in R using leaflet?
What I want:
1- I want to make markers appear with different colors
2- my map will have radio button to control (show/hide) markers by variable ‘color_status’
3- match color scale to the color of the markers –
sample of my code is here:
Ho to make markers have different colors base on specific variable in R using leaflet?
start_stations <- data.frame( station = c(“StreeterDr”, “MichiganAve”, “WellsSt”, “Highwayzone”), lat = c(25.27091982, 25.28078061, 25.2842742,25.28212071), lng = c(51.53083782,51.51318414,51.50223763,51.54843926), status = c(“high”, “medium”, “low”, “extreme_low”), status_code = c(1, 2, 3, 4) ) library(leaflet) library(leaflet.extras) long <- as.integer(start_stations$lng) lat <-as.integer(start_stations$lat)station_name <- start_stations$station color_satus <- start_stations$status status_code <- start_stations$status_code data_station <- as.data.frame(cbind(long,lat,station_name,color_satus, status_code)) pal <- colorFactor( palette = c(“#5F11A3″,”#FF1300″,”#0F0065”, […]