Are tabs with their own sidebars and mainPanels possible in shiny?

后端 未结 3 1223
一生所求
一生所求 2020-12-24 02:40

I would like to display different inputs for different tabs. So I tried to build a page with several tabPanels. However, I can\'t have sth like below:

librar         


        
3条回答
  •  清酒与你
    2020-12-24 02:57

    If I do not misunderstand your question, I think you can even evade the jQuery part (from @f1r3br4nd answer) by supplying an id for the tabsetPanel function, here id = "conditionedPanels". The value parameter (i.e. which tab is selected in the main panel) is then available via the input variable.

    A minmal example: server.R may be empty except for the shinyServer function skeleton. The ui.R file might be as follows.

    shinyUI(pageWithSidebar(
      headerPanel("Conditional Panels"),
      sidebarPanel(
        conditionalPanel(condition="input.conditionedPanels==1",
                         helpText("Content Panel 1")
        ),
        conditionalPanel(condition="input.conditionedPanels==2",
                         helpText("Content Panel 2")
        ) 
      ),
      mainPanel(
        tabsetPanel(
          tabPanel("Panel 1", value=1), 
          tabPanel("Panel 2", value=2)
          , id = "conditionedPanels"
        )
      )
    ))
    

提交回复
热议问题