使用列控制Shiny仪表板中的tabBox内容

Kir*_*-CO 3 r shiny shinydashboard

我正在尝试构建一个Shiny仪表板页面,该页面将包含带不同类型图表的选项卡式页面,允许用户动态更改设置等。从Shiny Dashboards页面的标准演示代码开始,我可以得到一个叠加版本的页面(https://rstudio.github.io/shinydashboard/structure.html#tabbox):

library(shiny)
  library(shinydashboard)

  body <- dashboardBody(
     fluidRow(
        tabBox(
           title = "First tabBox",
           # The id lets us use input$tabset1 on the server to find the current tab
           id = "tabset1", 
           tabPanel("Tab1", "First tab content", plotOutput('test')),
           tabPanel("Tab2", "Tab content 2")
        ),
        tabBox(
           side = "right", 
           selected = "Tab3",
           tabPanel("Tab1", "Tab content 1"),
           tabPanel("Tab2", "Tab content 2"),
           tabPanel("Tab3", "Note that when side=right, the tab order is reversed.")
        )
     ),
     fluidRow(
        tabBox(
           # Title can include an icon
           title = tagList(shiny::icon("gear"), "tabBox status"),
           tabPanel("Tab1",
                    "Currently selected tab from first box:",
                    verbatimTextOutput("tabset1Selected")
           ),
           tabPanel("Tab2", "Tab content 2")
        )
     )
  )

  shinyApp(
     ui = dashboardPage(
        dashboardHeader(title = "tabBoxes"),
        dashboardSidebar(),
        body
     ),
     server = function(input, output) {
        # The currently selected tab from the first box
        output$tabset1Selected <- renderText({
           input$tabset1
        })
        output$test = renderPlot(
           boxplot(len ~ dose, data = ToothGrowth,
             boxwex = 0.25, at = 1:3 - 0.2,
             subset = supp == "VC", col = "yellow",
             main = "Guinea Pigs' Tooth Growth",
             xlab = "Vitamin C dose mg",
             ylab = "tooth length",
             xlim = c(0.5, 3.5), ylim = c(0, 35), yaxs = "i"))
     }
  )
Run Code Online (Sandbox Code Playgroud)

如果我将第10行修改为:

tabPanel("Tab1", column(4,"First tab content"), 
                 column(8, plotOutput('test'))
                 ),
Run Code Online (Sandbox Code Playgroud)

我将标题和箱线图分成几列,但tabBox不再扩展以包含它们。

有什么方法可以控制tabPanel的内容以允许输出的列格式?

K. *_*hde 5

只需将列包装在fluidRow或内fluidPage。然后,将tabPanel获得正确的大小并延伸以适合您的列。