Interactive choropleth map with R Shiny and flyers.

I am trying to create a brilliant application where I can select the value that I want to add to my map. This may be a very simple task, but I'm new to Shiny, and I can't figure it out.

I don’t understand if I need to use selectInput or if the liquet has another way of interacting with Shiny.

This is my code.

library(RColorBrewer)
library(rgdal)
library(shiny)


pal <- colorQuantile("YlGn", NULL, n = 5)

state_popup <- paste0("<strong>State: </strong>", 
                      africa$COUNTRY, 
                      "<br><strong>Resource Revenue(IMF)</strong>", 
                      africa$Africa_r_1)

leaflet_africa <- leaflet(data = africa) %>%
  addProviderTiles("CartoDB.Positron") %>%
  addPolygons(fillColor = ~pal(Africa_r_1), 
              fillOpacity = 0.8, 
              color = "#BDBDC3", 
              weight = 1, 
              popup = state_popup)



ui <- fluidPage(
  leafletOutput("map1")
  )


server <- function(input, output, session) {

  output$map1 <- renderLeaflet({
    leaflet_africa
  })
}

shinyApp(ui = ui, server = server)
+4
source share

Source: https://habr.com/ru/post/1608039/


All Articles