闪亮仪表板中的条件面板

时间:2015-04-28 17:01:08

标签: r shiny dashboard

我对闪亮仪表板中的条件面板有疑问。是否有可能在 if(washerquestion){ // if washer == true or you can use else your_function(); } if(!washerquestion){ // if washer == false or you can use else your_function(); } 的{​​{1}}条件中创建条件面板?我的目标是在点击菜单标签menuItem后获得额外的sidebarMenu(但selectInput标签应保持隐藏状态。)

我正在做类似以下的事情

title2

在标准title1中,可以通过将ui <- dashboardPage( dashboardHeader(title = "Basic Dashboard"), dashboardSidebar( sidebarMenu( menuItem("tab title1", tabName = "name1", icon = icon("th")), menuItem("tab title2", tabName = "name2", icon = icon("th")) ), conditionalPanel( condition = "input.tabName == 'name2'", selectInput("period", "Period:", choices = list("Years" = 1, "Months" = 2)) ) ), dashboardBody()) 添加到标签来完成,但此处不起作用。有谁知道任何解决方案? 在此先感谢:)

1 个答案:

答案 0 :(得分:16)

id添加额外参数sidebarMenu可以解决问题。

ui <- dashboardPage(
dashboardHeader(title = "Basic Dashboard"),
dashboardSidebar(
    sidebarMenu(id="menu1",
        menuItem("tab title1", tabName = "name1", icon = icon("th")),
        menuItem("tab title2", tabName =  "name2", icon = icon("th"))
     ),
    conditionalPanel(
        condition = "input.menu1 == 'name2'",
        selectInput("period", "Period:", 
                    choices = list("Years" = 1, "Months" = 2))
    )
    ),
dashboardBody())