eventReactive()
provides a useful way to delay reactions when combined with an actionButton()
. To see this:
Remove eval = FALSE
from the code chunk below.
Add an actionButton()
like actionButton("go", "Go!")
to your document. Place it before the call to renderPlot()
.
Monitor the action button with eventreactive()
. Arrange for eventreactive()
to create a reactive expression that updates whenever the button is pressed. The expression should contain the results of iris[[input$iriscol]]
.
Remove iris[[input$iriscol]]
from the call to renderPlot()
. Have renderPlot()
call the reactive expression above in its place.
Re-render the document. Change the select box. What happens to the plot? Click the action button. What happens to the plot?
selectInput("iriscol", label = "Select a variable", choices = names(iris))
renderPlot({ # call the action button here hist(iris[[input$iriscol]], probability = TRUE) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.