我正在使用Shinyapp做一些测试。 有人知道有什么方法可以使用“文本输入”的值更新所有滑块的标签,而不必为每个滑块使用“ updateSliderInput”功能吗?
Pd:我粘贴了一个示例,但实际上是100个滑块
预先致意并致谢
ui <- fluidPage(
fluidRow(
textInput("caption", "Const1", "strong"),
box(width = 3, title = "box1",
solidHeader = TRUE, status = "danger",
# Sd slider:
sliderInput(inputId = "c11",
label = "Con1",
value = 5, min = 1, max = 5),
sliderInput(inputId = "c12",
label = "Con2",
value = 3, min = 1, max = 5,step = 1),
sliderInput(inputId = "c13",
label = "Con3",
value = 4, min = 1, max = 5),
sliderInput(inputId = "c14",
label = "Con4",
value = 3, min = 1, max = 5),
sliderInput(inputId = "c15",
label = "Con5",
value = 2, min = 1, max = 5)
),
box(width = 3, title = "box2",
solidHeader = TRUE, status = "danger",
# Sd slider:
sliderInput(inputId = "c21",
label = "Con1",
value = 2, min = 1, max = 5),
sliderInput(inputId = "c22",
label = "Con2",
value = 3, min = 1, max = 5,step = 1),
sliderInput(inputId = "c23",
label = "Con3",
value = 2, min = 1, max = 5),
sliderInput(inputId = "c24",
label = "Con4",
value = 4, min = 1, max = 5),
sliderInput(inputId = "c25",
label = "Con5",
value = 4, min = 1, max = 5)
)
)
)
# Define server logic required to draw
server <- function(input, output, session) {
observe({
text <- input$caption
updateSliderInput(session, "c11", label =text, value = 3 )
})
}
# Run the application
shinyApp(ui = ui, server = server)