title: Having trouble with leafletProxy, observeEvent and shiny / leaflet application
body: <p>For the last few hours I have been playing with my coding, using forms of if statements, observeEvent and leafletProxy, but I can't seem to get it working. The life table is life expectancy data. It is three columns, COUNTY, male, female. I can't seem to get the radio button to work and it always stays at male.</p>
  
  <p>Basically, I want my leaflet map to give different layouts based on the input of the radio button. Either getting male life expectancy and female, as well as getting the popup.</p>
  
  <pre><code>library(shiny)
  library(leaflet)
  library(tigris)
  library(dplyr)
  
  lnd &lt;- counties(state = 'IN', cb = TRUE, resolution = '20m')
  
  #Read life table
  life &lt;- read.table("life.txt",sep="\t", header=TRUE)
  
  lnd@data &lt;- left_join(lnd@data, life, by = c('NAME' = 'county'))
  
  popup &lt;- paste0("County name: ", lnd$NAME, "&lt;br&gt;", "Life Expectancy: ", round(lnd$male,2))
  popup2 &lt;- paste0("County name: ", lnd$NAME, "&lt;br&gt;", "Life Expectancy: ", round(lnd$female,2))
  
  
  ui &lt;- shinyUI(fluidPage(#theme = "bootstrap.css",
  
  titlePanel("Life Exptectancy in Indiana Counties: "),
  h3("A Spatial Analysis Project"),
  br(),
  sidebarLayout(position = "right",
  
              sidebarPanel(
                tags$b("Life Expectancy in Indiana, U.S.A."),
                hr(),
                radioButtons("gender",     "Gender:",c("Male"="Male","Female"="Female")),
  
                hr()
              ),
              mainPanel(
                leafletOutput("map")
              )
     )
  ))
  
  server &lt;- function(input, output) {
    output$map &lt;- renderLeaflet({
      leaflet(lnd) %&gt;%
        addPolygons() %&gt;%
        addProviderTiles(providers$CartoDB.Positron)
    })
    observeEvent (input$gender == "Male", {
      leafletProxy("map", data=lnd) %&gt;%
        clearShapes() %&gt;%
        addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1, popup = popup)
    })
    observeEvent (input$gender == "Female", {
      leafletProxy("map", data=lnd) %&gt;%
        clearShapes() %&gt;%
        addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1, popup = popup2)
    })
  }
  shinyApp(ui, server)
  </code></pre>
  
  <p>This is a photo of my app<a href="https://i.stack.imgur.com/ZPbds.jpg" rel="nofollow noreferrer">The app remains blue, and keeps the same male data no matter if I click female or male. I know it has to do with something with leafletProxy but cant figure it out</a></p>