【发布时间】:2021-09-04 13:48:54
【问题描述】:
我需要在 Shiny 的其他输入功能中添加一些输入,我不知道该怎么做,我已经完成了一个 renderUI,然后是一个 uiOutput,但我没有功能...... 我添加代码:
inputs = function(dades1){
for (i in 1:ncol(dades1)) {
if (dades1[i]=="Edad") {
insertUI(
selector = "$Edad",
where = "afterEnd",
multiple = TRUE, immediate = TRUE,
ui = radioButtons( inputId = "sel1",
choices = c("1","0"),
selected = c(1,0)))
}
else if (dades1[i]=="Gender") {
insertUI(
selector = "$Gender",
where = "afterEnd", multiple = TRUE, immediate = TRUE,
ui =
radioButtons( inputId = "sel2",
choices = c("1","0"),
selected = c(1,0)))}}}
(我已经缩短了函数,但还有更多的 'else ifs') 然后一旦完成我添加到服务器的功能:
output$cc<-renderUI({
dades1<-select(cov,input$vars)
dades1<-cbind(UCI,dades1)
inputs(dades1)
})
最后到 ui:
uiOutput("cc"),
【问题讨论】:
-
您的问题不完整,因为您只提供了应用程序的一部分,因此很难提供答案。下次您将创建一个问题时,请记住它必须是可重现的。你不应该在
renderUI中使用insertUI。insertUI背后的想法是在例如内部使用它。observeEvent。我认为你应该重写你的应用程序。也请查看shinyjs::hide/shinyjs::show,他们可能就是您要找的。span>
标签: r function user-interface shiny