Collect All user inputs throughout the Shiny App

For accessing all inputs, you can use reactiveValuesToList server-side. You can access input values via Javascript Events like below (I have taken the example from @Pork Chop) :

library(shiny)

ui <- basicPage(

  fluidRow(
    column(
      width = 6,
      textInput('a', 'Text A',"a1"),
      textInput('b', 'Text B',"b1"),
      textInput('c', 'Text A',"c1"),
      textInput('d', 'Text B',"d1"),
      textInput('e', 'Text A',"e1"),
      textInput('f', 'Text B',"f1")
    ),
    column(
      width = 6,
      tags$p("Text A :", tags$span(id = "valueA", "")),
      tags$script(
        "$(document).on('shiny:inputchanged', function(event) {
          if (event.name === 'a') {
            $('#valueA').text(event.value);
          }
        });
        "
      ),
      tableOutput('show_inputs')
    )
  )
)

server <- shinyServer(function(input, output, session){

  AllInputs <- reactive({
    x <- reactiveValuesToList(input)
    data.frame(
      names = names(x),
      values = unlist(x, use.names = FALSE)
    )
  })

  output$show_inputs <- renderTable({
    AllInputs()
  })
})
shinyApp(ui = ui, server = server)

Leave a Comment