changing the fillColor of selectInput for factor dataType doesn't work

Hi there,

I have been able to create the selectInput on the UI based on the factor datatype column. I am also able to fill the polygons with color but on selection of the data levels in the UI dropdown, the polygons do now change.

The levels are:

Levels: 50.0-54.9 55.0-59.9 60.0-64.9 65.0-69.9 above 69.9


library(leaflet)
library(rgdal)
library(sp)
library(shiny)
library(viridis)


# factor datatype column used 
vars_noise <- levels(noisePollution$NoiseClass)

# UI
selectInput("noise", "Select noise class:", vars_noise), # road noise pollution polygon


# server
observe({
      # interactive variables for noise
      colorByNoise <- input$noise
      colorDataNoise <- noisePollution[[colorByNoise]]
      pal3 <- colorFactor(viridis(5), domain = noisePollution$colorDataNoise)

      leafletProxy("map", data = noisePollution) %>%
        # clearShapes() %>%
        addPolygons(group = "noisePollution", color = "black", weight = 1, smoothFactor = 0.5,
                    opacity = 1.0, fillOpacity = 1.0,
                    fillColor = ~pal3(colorDataNoise),
                    highlightOptions = highlightOptions(color = "grey", weight
                                                        = 2,
                                                        bringToFront = TRUE)
        )

    })


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.