The reactive and isolate functions

If you need to call an input argument inside many output objects, you must create a reactive expression using the reactive function. Let's see an example:

library(shiny)#the UI objectui <- fluidPage(numericInput(inputId = "number",                             label = "A number between 1 and 50:",                             value = 1, min = 1, max = 50, step = 1),                textInput(inputId = "text", label = "A text box",                           value = ""),                tableOutput(outputId = "table_a"),                tableOutput(outputId = "table_b"))#the server functionserver <- function(input, output) {  the_number <- reactive({input$number})  output$table_a <- renderTable(list(input$text, the_number()))  output$table_b <- renderTable(list(the_number(),                                      isolate({input$text})))}#Run the appshinyApp (ui = ui, server ...

Get Hands-On Data Science with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.