我有一个
sidebarLayout dashboard
,不同的输入变得混乱。我想将它们放在 3 个不同的菜单项下,如下图所示。
下面的代码有可能吗?
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
pickerInput("A", "A", choices = LETTERS[1:5]),
pickerInput("B", "B", choices = LETTERS[1:5]),
pickerInput("C", "C", choices = LETTERS[1:5]),
pickerInput("D", "D", choices = LETTERS[1:5]),
pickerInput("E", "E", choices = LETTERS[1:5]),
pickerInput("F", "F", choices = LETTERS[1:5]),
textInput("G", "G"),
textInput("H", "H"),
textInput("I", "I"),
textInput("J", "J"),
textInput("K", "K"),
numericInput("L", "L", 1),
numericInput("M", "M", 1),
numericInput("N", "N", 2),
numericInput("O", "O", 3),
numericInput("P", "P", 4),
numericInput("Q", "Q", 4)
),
mainPanel()
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
您可以尝试使用可折叠面板。如果您不想推出自己的折叠功能,请查看 shinyBS 是否适合您。
library(shiny)
library(shinyWidgets)
library(shinyBS)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
bsCollapse(
id = "collapsedMenus",
bsCollapsePanel(
"Picker Settings",
pickerInput("A", "A", choices = LETTERS[1:5]),
pickerInput("B", "B", choices = LETTERS[1:5]),
pickerInput("C", "C", choices = LETTERS[1:5]),
pickerInput("D", "D", choices = LETTERS[1:5]),
pickerInput("E", "E", choices = LETTERS[1:5]),
pickerInput("F", "F", choices = LETTERS[1:5]),
style = "primary"
),
bsCollapsePanel(
"Text Settings",
textInput("G", "G"),
textInput("H", "H"),
textInput("I", "I"),
textInput("J", "J"),
textInput("K", "K"),
style = "success"
),
bsCollapsePanel(
"Numeric Settings",
numericInput("L", "L", 1),
numericInput("M", "M", 1),
numericInput("N", "N", 2),
numericInput("O", "O", 3),
numericInput("P", "P", 4),
numericInput("Q", "Q", 4)
)
)
),
mainPanel()
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)