简体   繁体   English

多个滑块的闪亮名称

[英]Shiny name of multiple sliders

I have a big and complex code.我有一个大而复杂的代码。

I have created a uiOutput("sliders") in the ui in order to have some sliders (depending on the number of columns of a dataset I am able to upload).我在 ui 中创建了一个 uiOutput("sliders") 以便有一些滑块(取决于我能够上传的数据集的列数)。 In the server I have the following code:在服务器中,我有以下代码:

output$sliders <- renderUI({
    pvars <- file_col()/2-1
    myList<-list()
    lapply(seq(pvars), function(i) {
    
        sliderInput(inputId = paste0("Shiftindex", i),label = ("Shift index")
                    ,min = 0, max = 1,value= 0,step = 0.1)
    }
    )

  })

I want to use the value of each sliderInput again in the server in order to compute something else.我想在服务器中再次使用每个滑块输入的值来计算其他东西。 My question is how I can put names in the sliders in order to be able to use their values in the server again and how I have to call them??我的问题是如何将名称放在滑块中以便能够再次在服务器中使用它们的值以及如何调用它们?

You can access their values on the server side with input[[paste0("Shiftindex", 1)]] for example.例如,您可以使用input[[paste0("Shiftindex", 1)]]在服务器端访问它们的值。

You could do something like the following:您可以执行以下操作:

output$text <- renderText({
  pvars <- file_col()/2-1   
  slider_inputs <- paste0("Shiftindex", seq(pvars))   
  values <- purrr::map_dbl(slider_inputs, function(x) input[[x]])   
  paste(values, collapse = ", ") 
})

Just let me know if you need extra help :)如果您需要额外的帮助,请告诉我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM