eventReactive() provides a useful way to delay reactions when combined with an actionButton(). To see this:

  1. Remove eval = FALSE from the code chunk below.

  2. Add an actionButton() like actionButton("go", "Go!") to your document. Place it before the call to renderPlot().

  3. 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]].

  4. Remove iris[[input$iriscol]] from the call to renderPlot(). Have renderPlot() call the reactive expression above in its place.

  5. 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)
})


rstudio/reportsWS documentation built on May 28, 2019, 5:42 a.m.