gpt4 book ai didi

r - Shiny 布局,是否可以在 Shiny 中设置左侧和侧边栏布局?

转载 作者:行者123 更新时间:2023-12-05 03:49:37 24 4
gpt4 key购买 nike

在 Shiny 中可以有这样的布局吗?

enter image description here

理想情况下,我想要左右侧边栏(我在 shinydashboardPlus 中看到了一些解决方案,但这并不是我所追求的......)

我有一个结构与此示例类似的应用:

mychoices <- c("pick me A", 
"pick me - a very long name here",
"no pick me - B",
"another one that is long")

ui <-
navbarPage(
tabPanel("Dataset description",
),
tabPanel("Data",
sidebarLayout(
sidebarPanel(
fluidRow(
column(2,
p(strong("Classes")),
actionButton(inputId = "selectall", label="Select/Deselect all",
style='padding:12px; font-size:80%'),
br(), br(),
checkboxGroupButtons(
inputId = "classes",
choices = mychoices,
selected = mychoices,
direction = "vertical",
width = "100%",
size = "xs",
checkIcon = list(
yes = icon("ok",
lib = "glyphicon"))
),
),
column(6,
br()
),
column(4,
p(strong("Controls")),
p("Transparency"),
sliderInput("trans", NULL,
min = 0, max = 1, value = .5),
actionButton("resetButton", "Zoom/reset plot",
style='padding:6px; font-size:80%'),
actionButton("clear", "Clear selection",
style='padding:6px; font-size:80%'),
actionButton("resetColours", "Reset colours",
style='padding:6px; font-size:80%'),
)
)
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Scatter", id = "panel1",
plotOutput(outputId = "scatter")),
tabPanel("PCA", id = "panel2"))
)
))
)


server <- function(input, output) {}

shinyApp(ui, server)

enter image description here

理想情况下,我想拆分 sidebarLayout,这样一列在左边(类),一列在右边(控件),因为当应用加载时,两列是 overlapping like this .

有什么关于更好的应用设计或解决方案的建议吗?

最佳答案

也许这就是您要找的。只是一个想法……所以我放弃了 sidebarLayout 并添加了第二个 sidebarPanel。为了确保侧边栏和主面板都排成一行,我使用了 width 参数。

library(shiny)
library(shinyWidgets)

mychoices <- c(
"pick me A",
"pick me - a very long name here",
"no pick me - B",
"another one that is long"
)

ui <-
navbarPage(
tabPanel("Dataset description", ),
tabPanel(
"Data",
sidebarPanel(
width = 3,
p(strong("Classes")),
actionButton(
inputId = "selectall", label = "Select/Deselect all",
style = "padding:12px; font-size:80%"
),
br(), br(),
checkboxGroupButtons(
inputId = "classes",
choices = mychoices,
selected = mychoices,
direction = "vertical",
width = "100%",
size = "xs",
checkIcon = list(
yes = icon("ok",
lib = "glyphicon"
)
)
)
),
mainPanel(
width = 6,
tabsetPanel(
type = "tabs",
tabPanel("Scatter",
id = "panel1",
plotOutput(outputId = "scatter")
),
tabPanel("PCA", id = "panel2")
)
),
sidebarPanel(
width = 3,
p(strong("Controls")),
p("Transparency"),
sliderInput("trans", NULL,
min = 0, max = 1, value = .5
),
actionButton("resetButton", "Zoom/reset plot",
style = "padding:6px; font-size:80%"
),
actionButton("clear", "Clear selection",
style = "padding:6px; font-size:80%"
),
actionButton("resetColours", "Reset colours",
style = "padding:6px; font-size:80%"
)
)
)
)


server <- function(input, output) {}

shinyApp(ui, server)

enter image description here

关于r - Shiny 布局,是否可以在 Shiny 中设置左侧和侧边栏布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63837387/

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