小编Zhe*_*ang的帖子

从 SelectInput (RShiny) 中的选项分组列表中获取组标签

如何从带有selectInput分组选项的下拉框中选定的输入中获取组名称?Building例如,在选择Bankwithin之后BuildingNature在选择Bankwithin之后如何获取Nature

更新的示例:

# demoing optgroup support in the `choices` arg
shinyApp(
  ui = fluidPage(
    selectInput("state", "Choose a word:",
      list(`Building` = list("Apartment", "Bank", "Hospital"),
           `Nature` = list("Bank", "River", "Orange"),
           `Color` = list("Blue", "Orange", "Red"))
    ),
    textOutput("result")
  ),
  server = function(input, output) {
    output$result <- renderText({
      paste("You chose", input$state)
    })
  }
)
Run Code Online (Sandbox Code Playgroud)

一种方法是存储所有选项及其分组标签的变量,并搜索该选项来自哪个组。但当群体之间存在重叠选择时,这就不起作用了。

r shiny selectinput

5
推荐指数
1
解决办法
1246
查看次数

标签 统计

r ×1

selectinput ×1

shiny ×1