Exchange map results using leaflet and state_popup

Asked

Viewed 36 times

1

I have a database of medical appointments by city. I use the leaflet and state_popup function to display the results on a map, as described below:

pal <- colorBin("Blues",domain = DATA$QUANTITY_MEDICAL,bins = c(1, 1000, 5000, 10000, 50000,100000,300000),na.color=NA) 

state_popup <- paste0("<strong>CITY: </strong>", 
                      DATA$CITY, 
                      "<br><strong> QUANTITY OF MEDICAL CONSULTATION: </strong>", 
                      DATA$QUANTITY_MEDICAL)

leaflet(data = DATA) %>%
    addProviderTiles("CartoDB.Positron") %>%
    addPolygons(fillColor = ~pal(QUANTITY_MEDICAL), 
                fillOpacity = 0.7, 
                color = "#BDBDC3", 
                weight = 1, 
                popup = state_popup) %>%
    addLegend("topright","bottomright", pal = pal, values = ~ DATA$QUANTITY_MEDICAL,
              title = " QUANTITY OF MEDICAL CONSULTATION ",
              opacity = 1)

This script only shows one result at a time (medical appointments). I would like to include information on other medical procedures that I intend to include, such as examinations or hospitalizations. I want, for each procedure (medical consultation, examination or hospitalization) to include a button that changed the result. In my base (DATA) I already have the columns that separate the procedures I mentioned. It is possible to include this button to exchange the results in the map?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.