参考:Using Action Buttons主要是要设计一个全局变量,可以进行多次active即可:
library(shiny)ui <- fluidPage(actionButton(inputId = "runif",label = "runif"),actionButton(inputId = "reset",label = "reset"),textOutput("text"),plotOutput("hist"))server <- function(input, output) {v <- reactiveValues(data = NULL)observeEvent(input$runif, {v$data <- runif(100)})observeEvent(input$reset, {v$data <- NULL})output$hist <- renderPlot({if (!is.null(v$data)) {hist(as.numeric(v$data))}})output$text <- renderText({if (!is.null(v$data)) {paste("v$data is ploted to histogram")} else {paste("v$data is reseted to NULL")}})}shinyApp(ui = ui, server = server)

runif和reset控件都是在控制v$data这个变量!
