Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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:

library(shiny)  shinyUI(pageWithSidebar(   headerPanel("Header"),    tabsetPanel(     tabPanel(       headerPanel("Tab 1"),       sidebarPanel(         selectInput("var", "Parametre", choices = c("1", "2", "3"))         ),       mainPanel(         textOutput("text1")         )       ),     tabPanel(       headerPanel("Tab 2"),       sidebarPanel(         selectInput("var", "Parametre", choices = c("21", "22", "23"))       ),       mainPanel(         textOutput("text2")       )     )     )   )) 

I suspect that the pageWithSidebar is causing the problem, but I couldn't find an alternative in google groups. Is there a way to display several tabs with their own sidebars and mainPanels, or shall I create different apps for this purpose?

like image 507
barerd Avatar asked Apr 25 '13 21:04

barerd


People also ask

How do you make multiple tabs shiny?

Tabsets are created by calling the tabsetPanel function with a list of tabs created by the tabPanel function. Each tab panel is provided a list of output elements which are rendered vertically within the tab.

What is TabSet?

A TabSet is comprised of many TabStops. It offers methods for locating the closest TabStop to a given position and finding all the potential TabStops. It is also immutable. Warning: Serialized objects of this class will not be compatible with future Swing releases.


1 Answers

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"     )   ) )) 
like image 156
Mark Heckmann Avatar answered Sep 21 '22 15:09

Mark Heckmann