Home > other >  How to use paste0 with input$ in shiny
How to use paste0 with input$ in shiny

Time:11-21

This is a follow up question to this enter image description here

I have tried:

  # Reactive expression to create data frame of all input values ----
  sliderValues <- reactive({
    
    data.frame(
      Name = c(LETTERS[1:3]),
      Value = paste0("input$", letters[1:3]),
      stringsAsFactors = FALSE)
  })

enter image description here

CodePudding user response:

One option would be to use sapply or ...

# Reactive expression to create data frame of all input values ----
  sliderValues <- reactive({
    
    data.frame(
      Name = c("A",
               "B",
               "C"),
      Value = as.character(sapply(letters[1:3], function(x) input[[x]])),
      stringsAsFactors = FALSE)
    
  })
  • Related