Get Values from Sliders & Select Inputs Created by Taglist

I'm able to create multiple sliders and selections dynamically (data driven) in Shiny UI but don't know how to retrieve resulting user selected values. My objective is to use the selected values in other functions.

Does someone know the syntax to retrieve these values? Here's an example for the sliders:

ui <- fluidPage(

server <- function(input, output) {
output$sliders <- renderUI({
c <- c("A", "B", "C")
min <- c(10,100,1000)
max <- c(50,500,5000)
sliders <- lapply(1:length(c), function(i) {
inputName <- c[i]
min <- min[i]
max <- max[i]
sliderInput(inputName, inputName, min=min, max=max, value=0)
}), sliders)

# don't know how to retrieve slider values??
output$values <- renderTable({
    d <- data.frame(input$inputName)


shinyApp(ui = ui, server = server)

Away from my computer so haven't run it but I would guess.


Your idea works when I explicitly type input$A, but you can see I need to build input$A dynamically since A is only known when a dataframe of new variables is brought in. So maybe my issue is how do I construct 'input$A' dynamically so the server recognizes this is referring to the slider input values?

When I construct a value through paste my table simply returns the paste string and not the slider value. For example, if c below is a vector of values testA, testB, testC, I get a return vector of values which just have the words in input$testA, input$testB, input$testC. My expectation is to get the numerical values from the sliders like 50, 210, 1008 (as examples).

Maybe I am rendering the paste function incorrectly for this use case?

values <- paste0("input$", c, sep = '')

Nice, I think this will work.

My approach was more brute force since I've only been working with shiny\R for a year, and I was thinking I was only one issue away from the answer. I'll try your suggestion even though several of the functions & syntax are foreign to me, and I'll need to get this to work for select inputs too.

Appreciate your quick response and ideas.

working on it..........

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.