[英]accessing inputs created in renderUI in Shiny
I am trying to utilize a bit of dynamic gui activity in an application on Shiny server. 我试图在Shiny服务器上的应用程序中使用一些动态gui活动。 My application needs a variable number of sliders created, depending on data that is input into my application.
我的应用程序需要创建可变数量的滑块,具体取决于输入到我的应用程序中的数据。 Specifically, I am trying to create sliders that set a value, one for each unique category in a input data table.
具体来说,我正在尝试创建一个为输入数据表中的每个唯一类别设置一个值的滑块。 I am able to successfully read my input table and create the sliders, using render UI, but I am stuck on how to best then manipulate the variable number of created input values set by the sliders - how do I go about accessing them (as a list, preferably?) Appreciate any advice or pointers.
我能够使用渲染UI成功读取我的输入表并创建滑块,但我仍然坚持如何最好地操纵滑块设置的可变数量的创建输入值 - 如何访问它们(作为列表,最好?)欣赏任何建议或指针。 My code snippet is below.
我的代码片段如下。
output$sliders <- renderUI({
# if we don't need the sliders, return
if (input$unequalpts == "no")
return(NULL)
# go to panel where sliders are to appear
updateTabsetPanel(session, "inTabSet", selected = "Unequal")
# get the number of unique entries the field f interest to create sliders for
theDATA <- myData()
theFields <- unique(as.character(theDATA$shnystr))
return (
lapply(1:numstrata, function(i) {
sliderInput(inputId = paste0("strata", i), label = paste("strata ", theFields[i]),
min = 0, max = 100, value = c(0, 100), step = 1)
})
)
})
It is common to use input$foo
to retrieve the value of the input widget that has the id foo
. 通常使用
input$foo
来检索具有id foo
的输入窗口小部件的值。 In fact, you can also use input[['foo']]
, so in your case, you just pass the id's to input
and retrieve their values like this: 实际上,你也可以使用
input[['foo']]
,所以在你的情况下,你只需将id传递给input
并检索它们的值,如下所示:
lapply(1:numstrata, function(i) {
input[[paste0("strata", i)]]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.