Skip to content

Instantly share code, notes, and snippets.

@trinker
Last active August 10, 2017 12:39
Show Gist options
  • Select an option

  • Save trinker/0e2fb5a11e6a1fde34901f5289e3c7d1 to your computer and use it in GitHub Desktop.

Select an option

Save trinker/0e2fb5a11e6a1fde34901f5289e3c7d1 to your computer and use it in GitHub Desktop.
Shiny: Truck Button Clicks
## reactiveValues makes a list of values that are reactive that can be altered
## by observe event. These reactives are then acted on in the server.R and
## passed back to the ui.R
library(shiny)
ui <- fluidPage(
actionButton(inputId = "clicker", label = "Next"),
textOutput("buttonval")
)
server <- function(input, output) {
rv <- reactiveValues(data = 1)
observeEvent(input$clicker, { rv$data <- rv$data + 1 })
output$buttonval <- renderText({
paste0('Click #', rv$data)
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment