I have created a map where i have plotted population density with a shapefile using the Leaflet package. I'am trying to loop through each polygon on the map, is this possible and how could do it?
**Map: Leaflet map
#Create Leaflet map
map <- leaflet() %>% addTiles() %>%
setView(lng = -7.1050, lat=53.2000,zoom=8) %>%
addPolygons(data=m,weight=1, popup = map_popup2, fillOpacity = .5) %>%
addCircleMarkers(data = m, lng = ~long_xcord,
lat = ~lat_ycord, radius=.5, color="green") %>%
addCircles(data = m, lng = ~long_xcord,
lat = ~lat_ycord, popup = map_popup,
radius = 4828.03, fillOpacity = 0.1, #3218.69 = 2 miles
color = 'black', fillColor = 'blue',weight = 2, label=m$` name`) %>%
addLegend("bottomright", pal = heat, values = m$pop,
title = "Population",
opacity = 1)