Inspired in this answer [Collect All user inputs throughout the Shiny App I could get all the inputs values. However, I want also the label of each shiny input.
Is there any way to get all LABELS of each input in Shiny?
Below the R-Shiny code:
library(shiny)
ui<- fluidPage(
titlePanel("Dynamically generated user interface components"),
fluidRow(
column(3,
selectInput("cnt_id", "Country",
c("USA", "Cananada", "Mexico"),
),
selectInput('cod_id', 'Code', c(Choose='', c("c12","c13","c14")), selectize=FALSE),
uiOutput("rtxt")
),
column(3,
#tags$p("Pais"),
#verbatimTextOutput("d1"),
#tags$p("Code"),
#verbatimTextOutput("d2"),
br(),
tableOutput('show_inputs')
)
)
)
server <- function(input, output) {
output$rtxt<- renderUI({
textInput('text_id', label = 'Type comment')
})
#Get inputs
AllInputs <- reactive({
x <- reactiveValuesToList(input)
data.frame(
names = names(x),
values = unlist(x, use.names = FALSE)
)
})
#display inputs
output$show_inputs <- renderTable({
AllInputs()
})
}
shinyApp(ui = ui, server = server)
The ideal output would be a table like:
+--------------+----------------+
| Input_Label | Input_Value |
+--------------+----------------+
| Country | USA |
| Code | c12 |
| Type comment | some comment |
+--------------+----------------+
The answer can also include JavaScript
, in case it's neccesary.
Thanks in advance