title: color mapping polygons based on user input
body: <p>I want to color map my polygons based on the user input. The column i am using has categorial variables so I am using the colorFactor function which I have tested it is functioning normally. The issue is with the observe function when I load my shiny app it terminates immediately and outputs "Error in addPolygons: unused argument (fillcolor = ~pal(AreaTyp)) in leaflet".My question is how to include reactivity correctly using the observe function. Here is my code:</p>
  
  <pre><code>#INTERACTIVE MAPPING
    #colorfunction
    pal&lt;-colorFactor(rainbow(7),mp$AreaTyp)
  
    #set data based on user input
    fdata&lt;-reactive({
      data&lt;-mp
      if(input$area!="All"){
        data&lt;-data[data$AreaType==input$area,]
      }
      data
    })
  
  
  
    output$leaf&lt;-renderLeaflet({
  
      leaflet(fdata()) %&gt;%
  
        #Initializing the map
        setView(lng=36.092245, lat=-00.292115,zoom=15)%&gt;%
  
        #Base map
        #Add default OpenStreetMap map tiles
        addTiles(group = "default")%&gt;%
        #addProviderTiles("Esri.NatGeoWorldMap",group = "default")%&gt;%  
        #addProviderTiles("CartoDB.Positron",group = "custom")%&gt;%
  
        #Overlay map
        addPolygons(
          data = fdata(),
          fillColor = "blue",
          weight = 1, smoothFactor = 0.5,
          opacity = 1.0, fillOpacity = 1.0,
          group = "basepoly",
          highlightOptions = highlightOptions(
            weight = 2,
            color = "red",
            fillOpacity = 0.7,
            bringToFront = TRUE
          ),label =~LIA
  
  
        )
  
  
    })
  
  
    observe({
  
      leafletProxy("leaf",data = fdata()) %&gt;%
  
  
        clearShapes() %&gt;%
        addPolygons(
          weight = 1, smoothFactor = 0.5,
          opacity = 1.0, fillOpacity = 1.0,
          data=fdata(),
          fillcolor = ~pal(AreaTyp),
          label =~LIA
  
        )
  
  
  
    })
  </code></pre>