AnswerBun.com

Is there anyone who can figure out why popups in my map function are not coming up on the map on click in R? Using leaflet

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

Add your own answers!

Related Questions

20.04LTS NetworkManager VPN – Always on

1  Asked on November 11, 2021 by thebluemoon

   

Permission of a mounted EXT4 for a specific user

1  Asked on November 11, 2021 by erik-steiner

     

Apache and Nginx

1  Asked on November 11, 2021 by nate-sturtz

   

Unable to perform DNS queries over IPv6 from laptop

1  Asked on November 11, 2021 by jay-schauer

   

Macbook iSight not working

2  Asked on November 9, 2021

   

Can’t run unity-control-center

1  Asked on November 9, 2021 by davegri

     

Disable warning messages about ntpd in syslog

1  Asked on November 9, 2021 by user2010

     

ERROR: NVIDIA driver is not loaded

10  Asked on November 9, 2021 by user869841

         

Dell G3 3590 microphone not working

3  Asked on November 9, 2021

       

Webcam in Ubuntu 20.04 works partly

2  Asked on November 9, 2021 by kasheftin

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP