3
我想为我的闪亮应用拥有动态选项卡。我试了下面的代码使用条件面板在闪亮的仪表板中添加动态选项卡
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
checkboxGroupInput("Tabs",
label = h4("tabpanel"),
choices = list("tabs" = "tabs"),
selected = NULL),
checkboxGroupInput("moreTabs",
label = h4("moretabpanel"),
choices = list("moretabs" = "moretabs"),
selected = NULL)
),
dashboardBody(
conditionalPanel(
condition = "input.Tabs == 'tabs'",
tabBox(
title = "intro",
id= "ttabs", width = 8, height = "420px",
tabPanel("Files", dataTableOutput("Files")),
conditionalPanel(
condition = "input.moreTabs == 'moretabs'",
tabPanel("Files1", dataTableOutput("Files1"))
)
)
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)
但是,我不成功地动态地使用标签面板。它只显示一个标签,并在检查时显示第二个标签。
谢谢您的回答,但我没有兴趣使用'renderUI ' –
'renderUI'就是这样做的方法。 – jdharrison
@AaghazHussain,我绝对更喜欢'renderUI'选项,但是你也可以使用'conditionalPanel'工作,但是必须改变'tabPanel'的'value'值。 –