title: In shiny, how to have a new actionButton when a different variable is selected?
body: <p>I have a simple task of printing the output of a call to <code>table()</code> on a selected variable.<br>
  I want to display the output when the button "Print" is clicked.</p>
  
  <p>In the following example, once the button is clicked, the output is always triggered when I change the selected variable.<br>
  If I clicked "Print", and then change the selected variable, I want the ouput to be gone, waited to be printed again when clicking "Print".</p>
  
  <p>Thank you!</p>
  
  <p><strong>Here is a reproducible example:</strong></p>
  
  <pre><code>library(shiny)
  data = iris
  
  ui = fluidPage(
      uiOutput("selectvar"),
      actionButton("print", "Print"),
      verbatimTextOutput("info")
  )
  
  server = function(input, output, session)
  {
      output$selectvar = renderUI({
          selectInput("selectedvar",
                      "Select variable",
                      choices = colnames(iris))
      })
  
      tab = reactive( table(data[[input$selectedvar]]) )
  
      observeEvent(input$print, {
          output$info = renderPrint( tab() ) 
      })
  
  }
  
  shinyApp(ui, server)
  </code></pre>