因此,我查看了以下链接以在执行操作时创建动态选项卡并创建带有自己的侧边栏的选项卡,但我似乎无法将 2 和 2 放在一起。
R Shiny - add tabPanel to tabsetPanel dynamically (with the use of renderUI)
Are tabs with their own sidebars and mainPanels possible in shiny?
有谁知道在动态创建选项卡后如何访问它们?此外,在这种情况下,renderUI 示例是否不好,因为它为每个操作创建了一个新的标题列表?
最佳答案
我要感谢所有在 stackoverflow 上帮助我解决这个问题的好人;这是最支持编程初学者的网站。
用户界面:
library(shiny)
shinyUI(navbarPage("TiGr",
tabPanel("File Input Page",
fluidPage("Input")),
tabPanel("Summary Statistics and Plots",
fluidPage("Statistics")),
tabPanel("Time Clusters",
fluidPage("cluster"),
actionButton("subClust", label = "Create Subcluster"),
uiOutput("tabs"),
conditionalPanel(condition="input.level==1",
helpText("test work plz")
),
conditionalPanel(condition="input.level==5",
helpText("hohoho")
)
)
))
服务器:
library(shiny)
shinyServer(function(input, output,session) {
output$tabs=renderUI({
Tabs<-as.list(rep(0,input$subClust+1))
for (i in 0:length(Tabs)){
Tabs[i]=lapply(paste("Layer",i,sep=" "),tabPanel,value=i)
}
#Tabs <- lapply(paste("Layer",0:input$subClust,sep=" "), tabPanel)
do.call(tabsetPanel,c(Tabs,id="level"))
})
}
)
关于r - 如何使用自己的内容制作动态 Shiny 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31704048/