title: selectInput is not responding to action button properly in my leaflet map shiny app
body: <p>I need to create an interactive map with leaflet package, where I can use a <code>selectInput</code> to control what data points to show on the map. I also want to  use the layer control button to select one or both layers (data points) to appear on the map. My code is shown below. </p>
  
  <p>I want the map to respond to <code>selectInput</code> only when  <code>go</code> button is clicked.  </p>
  
  <p>My code works when I select one item in the <code>selectInput</code> (map refreshes when I click <code>go</code>). 
  I found when I select the second item, initially I see error:  <code>subscript out of bounds</code>. When <code>go</code> clicked, both markers appear. 
  When I remove one of the two item selected, the map responds before the action button clicked. </p>
  
  <p>It appears that the <code>selectInput</code> is not responding to <code>action button</code> properly.  Does anyone know why that happens? What did I do wrong?  I spend hours trying to figure it out but no luck...... Thanks a lot in advance. </p>
  
  <pre><code>library(shiny)
  library(leaflet)
  
  
  hotels &lt;- read.table(text = "Hotel Year  latitude        longitude
                                A   2000  41.886337      -87.628472
                                B   2005  41.88819       -87.635199
                                C   2010  41.891113      -87.63301", 
                       header = TRUE)
  
  
  ui &lt;- fluidPage(
  
      selectizeInput(inputId = 'year', label='Choose Year:',
                     choices = c(2000,2005,2010),
                     multiple=TRUE,
                     options = list(
                         maxItems = 2,
                         placeholder = '',
                         onInitialize = I("function() { this.setValue(''); }"))),
      actionButton("go", "go"),
      leafletOutput("mymap")
  
  )
  
  server &lt;- function(input, output, session) {
  
      df_list = reactive ({
          input$go
  
          isolate(
              if (length(input$year)&gt;1) {
                  list(hotels[hotels$Year == input$year[1],], 
                       hotels[hotels$Year == input$year[2],])
              } else {
                  list(hotels[hotels$Year == input$year[1],])
              }
  
          )
      })
  
      output$mymap &lt;- renderLeaflet({
  
          map = leaflet()  %&gt;%
              addProviderTiles("OpenStreetMap.Mapnik") %&gt;% 
              addCircleMarkers( data = df_list()[[1]] ,
                                group = 'Data Markers 1',
                                lng = ~longitude,
                                lat = ~latitude,
                                radius = 10,
                                stroke = F,
                                fillOpacity = 0.9,
                                color = 'red')
          if ( length(input$year)&gt;1){
              map = map %&gt;% 
                  addCircleMarkers( data = df_list()[[2]] ,
                                    group = 'Data Markers 2',
                                    lng = ~longitude,
                                    lat = ~latitude,
                                    radius = 10,
                                    stroke = F,
                                    fillOpacity = 0.9,
                                    color = 'blue')
          }
  
          if ( length(input$year)&gt;1) {
              map = map %&gt;% 
                  addLayersControl(
                      overlayGroups = c('Data Markers 1', 'Data Markers 2'),
                      options = layersControlOptions(collapsed = FALSE) )
          } else {
              map = map %&gt;% 
                  addLayersControl(
                      overlayGroups = c('Data Markers 1'),
                      options = layersControlOptions(collapsed = FALSE) )
          }
  
      })
  }
  
  shinyApp(ui, server)
  </code></pre>