R SelectizeInput - ChoiceValues ChoiceNames 的类似解决方案?
R SelectizeInput - similar solution of ChoiceValues ChoiceNames?
我正在做一个小的 R/shinydashboard 项目,我必须在其中处理 ID 和名称:例如Warehouse_ID = 1、2、... --> Warehouse_Name = 多伦多、柏林...
由于我从数据框中生成了这些值,因此我使用了:
list_dc_id = unique(dc$id)
和 list_dc_name = unique(dc$city)
我想使用 list_dc_id
和 list_dc_name
通过 SelectizeInput/updateSelectizeInput(Server=TRUE) 生成值和显示的名称。
我能够使用带有 ChoiceValues ChoiceNames 的 checkboxGroupInput 来做一个复选框,但是,我正在寻找一个带有 selectize 的解决方案。我看到了其他一些帮助页面,但遗憾的是无法完全理解该解决方案。
先谢谢你了!
来自?shiny::selectInput
:
choices: List of values to select from. If elements of the list are
named, then that name — rather than the value — is displayed to the
user.
所以你必须做 choices = setNames(list_dc_id, list_dc_name)
。
我正在做一个小的 R/shinydashboard 项目,我必须在其中处理 ID 和名称:例如Warehouse_ID = 1、2、... --> Warehouse_Name = 多伦多、柏林... 由于我从数据框中生成了这些值,因此我使用了:
list_dc_id = unique(dc$id)
和 list_dc_name = unique(dc$city)
我想使用 list_dc_id
和 list_dc_name
通过 SelectizeInput/updateSelectizeInput(Server=TRUE) 生成值和显示的名称。
我能够使用带有 ChoiceValues ChoiceNames 的 checkboxGroupInput 来做一个复选框,但是,我正在寻找一个带有 selectize 的解决方案。我看到了其他一些帮助页面,但遗憾的是无法完全理解该解决方案。 先谢谢你了!
来自?shiny::selectInput
:
choices: List of values to select from. If elements of the list are named, then that name — rather than the value — is displayed to the user.
所以你必须做 choices = setNames(list_dc_id, list_dc_name)
。