gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 00:19:15 25 4
gpt4 key购买 nike

我正在尝试构建一个 Shiny 的仪表板页面,该页面将具有带有不同类型绘图的选项卡式页面,允许用户动态更改设置等。从 Shiny 仪表板页面中的标准演示代码开始,我可以获得堆叠版本的页面(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"))
}
)

如果我将第 10 行修改为:
tabPanel("Tab1", column(4,"First tab content"), 
column(8, plotOutput('test'))
),

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

有没有办法控制 tabPanel 的内容以允许输出的列格式?

最佳答案

只需将列包裹在 fluidRow 中即可或 fluidPage .然后 tabPanel获得合适的尺寸并拉伸(stretch)以适合您的列。

关于r - 使用列来控制 Shiny 仪表板中的 tabBox 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36321940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com