Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny making sub panels

Tags:

r

shiny

Is there a simple solution to making tab panels within the main tab panels created in R shiny?

Here is how I create the main panels:

mainPanel(
  tabsetPanel(id = "tabSelected",
    tabPanel("Tab1", uiOutput("Tab1")),
    tabPanel("Tab2", uiOutput("Tab2"))

I wanted to make new tabs within "Tab1" for various plots I would like to show. I attempted to nest the tabsetPanel function but that doesn't work. Thanks!

like image 378
Andy Avatar asked Mar 05 '14 18:03

Andy


People also ask

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.

Which function is used to add a shiny server component tabPanel ()?

Tab Panels 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.


1 Answers

Maybe because yforget to include them into a new sub-tabsetPanel ?

This works for me :

shiny::runApp(list(
  ui = bootstrapPage(

    tabsetPanel(id = "tabSelected",
      tabPanel("Tab1", uiOutput("Tab1")),
      tabPanel("Tab2", uiOutput("Tab2"))
    )

  ),
  server = function(input, output,session) {

    output$Tab1 <- renderUI({
      tabsetPanel(id = "subTabPanel1", 
        tabPanel("subTab11"),
        tabPanel("subTab12")
      )
    })

    output$Tab2 <- renderUI({
      tabsetPanel(id = "subTabPanel2", 
                  tabPanel("subTab21"),
                  tabPanel("subTab22")
      )
    })
  }
))
like image 125
Julien Navarre Avatar answered Sep 23 '22 05:09

Julien Navarre