title: R shiny, shinyjs, remove plot and draw it again if button is clicked
body: <p>I have an app that plots the Old Faithul data with k-means clusters once the user clicks on a specific button ("run k-means"). Now, I want to add a button that removes the plot again ("remove plot"). Following <a href="https://stackoverflow.com/questions/35136029/hide-show-outputs-shiny-r">Hide/show outputs Shiny R</a>
  I tried this:</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage(
  actionButton(inputId = "run_kmeans", label = "run k-means"),
  actionButton(inputId = "remove_plot", label = "remove plot"),
  conditionalPanel("output.show", plotOutput("plot"))
  )
  
  server &lt;- function(input, output) {
  v &lt;- reactiveValues(show = TRUE)
  
  clusters &lt;- eventReactive(input$run_kmeans, {
  kmeans(faithful, 2)
  v$show &lt;- TRUE
  })
  
  output$plot &lt;- renderPlot({plot(faithful, col = clusters()$cluster)})
  
  output$show &lt;- reactive({
  return(v$show)
  })
  
  observeEvent(input$remove_plot, {v$show &lt;- 0})
  
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>Unfortunately, now the "run k-means" button does not work anymore. Hence, I also tried it via <code>shinyjs</code>:</p>
  
  <pre><code>library(shiny)
  library(shinyjs)
  
  ui &lt;- fluidPage(
    useShinyjs(),
    actionButton(inputId = "run_kmeans", label = "run kmeans"),
    actionButton(inputId = "remove_plot", label = "remove plot"),
    plotOutput("plot")
  )
  
  server &lt;- function(input, output) {
    clusters &lt;- eventReactive(input$run_kmeans, {kmeans(faithful, 2)})
    output$plot &lt;- renderPlot({show(plot(faithful, col = clusters()$cluster))})
  
    observeEvent(input$remove_plot, {hide("plot")})
    }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>But now the plot is hidden "forever" and not shown again if "run k-means" is clicked - did I place the <code>show()</code> function wrongly? Who can help me with either one of the two approaches (or both)?</p>