【发布时间】:2019-12-06 11:23:06
【问题描述】:
我想将我的selectInput 数据分组,如下所述:https://shiny.rstudio.com/gallery/option-groups-for-selectize-input.html。除了组中只有一项的情况外,一切正常。
这是一个示例(第一个 selectInput 正确,第二个奇怪):
library(shiny)
ui <- fluidPage(
selectInput("country", "Select country", list(
"Europe" = c("Germany", "Spain"),
"North America" = c("Canada", "United States" = "USA")
)),
selectInput("country", "Select country", list(
"Europe" = c("Germany", "Spain"),
"North America" = c("Canada")
))
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
以及效果:
你知道怎么处理吗?
【问题讨论】:
-
使用
list()而不是c()列出每个组中的国家 - ..."North America" = list("Canada") -
太棒了! @H1,把它作为一个答案,我会接受它。
标签: r shiny grouping selectinput