简体   繁体   中英

R shiny making sub panels

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!

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")
      )
    })
  }
))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM