【问题标题】:Shiny selectizeInput with value and label fields带有值和标签字段的闪亮 selectizeInput
【发布时间】:2019-06-28 14:19:15
【问题描述】:
【问题讨论】:
标签:
javascript
r
shiny
selectize.js
【解决方案1】:
render 选项允许在 HTML 中设置项目。这是一个例子:
library(shiny)
itemValues <- c("foo", "bar")
itemNames <- sprintf("<span style='background-color:springgreen'>%s</span>",
itemValues)
items <- setNames(itemValues, itemNames)
shinyApp(
ui = fluidPage(
selectizeInput("id", "Label", choices = items,
options = list(render = I("
{
item: function(item, escape) { return '<div>' + item.label + '</div>'; },
option: function(item, escape) { return '<div>' + item.label + '</div>'; }
}")))
),
server = function(input, output) {}
)
【解决方案2】:
您可以在这里查看一些示例:shiny selectize examples
大部分高级选项都是通过选项设置的。这里有一个没有颜色的最小示例:
ui <- fluidPage(
selectizeInput('myInput',
label='Select',
choices=c('first choice' = 'c1'),
multiple = TRUE,
options = list(create = TRUE))
)