title: Hide shiny output
body: <p>How do you hide rendered <code>shiny</code> output?  Specifically, I have some figures/tables generated by <code>shiny</code> and I have a button, that when clicked should hide the figures/tables, and when clicked again should show them.  </p>
  
  <p>This is what I have so far (below), and it works somewhat, but where it's supposed to hide the <code>renderPlot</code> output, there is a big blank space in the document that I am trying to make go away.</p>
  
  <p>It should be possible to just copy and paste this code into Rstudio and hit run document (it's rmarkdown with shiny runtime).</p>
  
  <pre><code>---
  runtime: shiny
  ---
  
  ```{r, echo=F}
  actionButton("hide", "Hide")
  dat &lt;- data.frame(a=1:10, b=rexp(10, 1/10), c=letters[sample(1:24, 10)])
  renderTable({
      if (input$hide %% 2 == 1)
          dat
  })
  
  ```
  lodi dodi
  
  ```{r, echo=F}
  renderPlot({
      if (input$hide %% 2 == 1)
          plot(b ~ a, data=dat)
  })
  
  ```
  this text is separated by blank space, but it shouldn't be
  </code></pre>