title: How to use selectInput to map a subset of a dataframe
body: <p><a href="https://i.stack.imgur.com/TnYq4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TnYq4.jpg" alt="enter image description here"></a></p>
  
  <p>I have a df containing the following columns: Species | latitude | longitude.  I would like to create an app that allows the user to select a species, using selectInput, and have the long/lat information of that species plotted.  </p>
  
  <pre><code>    library(shiny)
  library(leaflet)
  
  
  fixInvase &lt;- read.csv("fixed2011_buff_invasives.csv")
  
  ### Subsetted data that I would like to map
  
  bTrefoil &lt;- subset(fixInvase, Species == "Birdsfoot Trefoil", 
                     select = c(Species, latitude, longitude))
  cThistle &lt;- subset(fixInvase, Species == "Canada Thistle", 
                     select = c(Species, latitude, longitude))
  cheatgrass &lt;- subset(fixInvase, Species == "Cheatgrass", 
                       select = c(Species, latitude, longitude))
  cBuckthorn &lt;- subset(fixInvase, Species == "Common Buckthorn", 
                       select = c(Species, latitude, longitude))
  
  ...
  
  
  
  ui &lt;- fluidPage(
    titlePanel("2011 NWCA Invasive Species"),
    mainPanel(
      leafletOutput("map"),
      br(), br(),
      tableOutput("results")),
    sidebarPanel(
      ### User chooses the species to map
      selectInput("speciesInput", "Species",
                  c("Birdsfoot Trefoil" = "bTrefoil", 
                    "Canada Thistle" = "cThistle",
                    "Cheatgrass" = "cheatgrass",
                    "Common Buckthorn" = "cBuckthorn"))
    ))
  
  server &lt;- function(input, output, session){
  
    ####
    output$map &lt;- renderLeaflet({
      filtered &lt;-
        fixInvase %&gt;%
        filter(Species== input$speciesInput
        )
      leaflet(filtered) %&gt;% addTiles() %&gt;%
        fitBounds(~min(longitude), ~min(latitude), ~max(longitude), ~max(latitude))
    })
    output$results &lt;- renderTable({
      filtered &lt;-
        fixInvase %&gt;%
        filter(Species == input$speciesInput
        )
      filtered
    })
  
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>In leaflet, I am able to plot a subset of the dataframe using:</p>
  
  <pre><code>bTrefoil &lt;- subset(fixInvase, Species == "Birdsfoot Trefoil", 
                     select = c(Species, latitude, longitude))
  leaflet(data = bTrefoil) %&gt;% addTiles() %&gt;%
    addMarkers(~longitude, ~latitude, popup = ~as.character(Species), label = ~as.character(Species))
  </code></pre>
  
  <p>But when I try to use selectInput to subset and plot the data I encounter errors.</p>
  
  <p>Is there a way to subset the df based on the users selection in selectInput, and have leaflet map only those points?  </p>