Ask Ubuntu Asked by divinew99 on December 18, 2020
I’m creating a map with leaflet with zip code and county polygons. I would like for the values for columns "GEOID10" and "percent" from data set df to popup when I click on their respective zip code polygons. I don’t get an error message when I run this code and the output is still a map, but I am unable to get any popups to show up. Can anyone see where I might have gone wrong? I have tried moving the addPolygons(txcounties…) after the addPolygons(df…) but nothing changed. Forgive me, I am a total R novice and just learned this summer.
enter map1 <- leaflet() %>%
addProviderTiles ("CartoDB.Positron") %>%
setView (-99.9, 31.97, zoom = 5) %>%
addPolygons(data = zips, fill = "white", fillOpacity = 0, weight = 0, stroke = FALSE)%>%
addPolygons(data = txcounties, fill = "white" , fillOpacity = 0, weight = 1, color =.
"black", label = txcounties$NAME) %>%
addPolygons(data = df, color = ~pal (percent), stroke = F, fillOpacity = 0.6, weight =
1, label = ~paste0(percent), popup = ~paste0(
GEOID10, "<br>",
"Zip Code: ", format(`GEOID10`), "<br>",
"% of NSLP enrolled in P-EBT : ", round(`percent`, 2), "<br>"))%>%
addPolygons(data = txcounties, fill = "white" , fillOpacity = 0, weight = 1, color =.
"black", label = txcounties$NAME) %>%
addLegend(position = "bottomright", pal = pal, values = df$percent, title = "percent
enrolled")
map1
“
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP