只有一个元素的 PickerInput 子类别
PickerInput subcategories with only one element
我一直在尝试从包含子类别的包 ShinyWidgets 中制作 pickerInput。
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Select / Deselect all"),
pickerInput(
inputId = "p1",
label = "Select all option",
choices = list(subA = c("a","b","c"),
subB = c("a"),
subC = c("a","b")),
multiple = TRUE,
options = list(`actions-box` = TRUE)
),
verbatimTextOutput("r1")
)
server <- function(input, output, session) {
output$r1 <- renderPrint(input$p1)
}
shinyApp(ui = ui, server = server)
问题是当一个子类别只有一个元素时,输出有点奇怪并且与其他子类别显示不一样。在我的示例中,我可以选择子类别的名称 (subB),但不能选择此子类别的元素 ("a")
有办法解决这个问题吗?
将其列为
choices = list(subA = list("a","b","c"),
subB = list("a"),
subC = list("a","b"))
我一直在尝试从包含子类别的包 ShinyWidgets 中制作 pickerInput。
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Select / Deselect all"),
pickerInput(
inputId = "p1",
label = "Select all option",
choices = list(subA = c("a","b","c"),
subB = c("a"),
subC = c("a","b")),
multiple = TRUE,
options = list(`actions-box` = TRUE)
),
verbatimTextOutput("r1")
)
server <- function(input, output, session) {
output$r1 <- renderPrint(input$p1)
}
shinyApp(ui = ui, server = server)
问题是当一个子类别只有一个元素时,输出有点奇怪并且与其他子类别显示不一样。在我的示例中,我可以选择子类别的名称 (subB),但不能选择此子类别的元素 ("a")
有办法解决这个问题吗?
将其列为
choices = list(subA = list("a","b","c"),
subB = list("a"),
subC = list("a","b"))