r - 当 selectize=F 时在 selectInput() 中选择多个选项
问题描述
如何在selectInput()
when中选择多个项目selectize=F
?
library(shiny)
library(shinydashboard)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
uiOutput("box1")
),
title = "DashboardPage"
),
server = function(input, output) {
output$box1<-renderUI({
box(
selectInput(inputId = "in", label = "Choose", choices = c('Short','A very short sentence.'),
selectize = F,multiple=T, size = 5, width = "150px")
)
})
}
)
解决方案
您所拥有的是允许多项选择。如果你添加verbatimTextOutput(outputId = "res")
这个(即使它是临时的)你可能会看得更清楚uiOutput("box1")
output$res <- renderPrint({input$`in`})
output$box1
server
library(shiny)
library(shinydashboard)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
uiOutput("box1"), # comma added here
verbatimTextOutput(outputId = "res") # this is added
),
title = "DashboardPage"
),
server = function(input, output) {
output$box1 <- renderUI({
box(
selectInput(inputId = "in", label = "Choose", choices = c('Short','A very short sentence.'),
selectize = F,multiple=T, size = 5, width = "150px")
)# ends the box
}) # ends output$box1
output$res <- renderPrint({input$`in`}) # this is added here - since 'in' is a keyword I would suggest a different id...
} # ends server call
) # ends shinyApp
推荐阅读
- python-3.x - 如何在 rfc-2822 时区之间转换?
- elasticsearch - 单个主机上的 delegate_to 不在 ansible 角色下工作
- flutter - 如何在 Flutter 中创建应用内通知提醒系统?
- amazon-web-services - 如果 AWS VPN 启动但 ping 不起作用,可能会发生什么问题?
- reactjs - 使用版本 7 中的反应挂钩表单上传文件?
- api - 动态字段的输入类型架构
- java - Java Serviceability Agent:如何获取方法参数名称
- python - 将信息从 dict 传递到 snakemake 会导致缺少输入文件错误
- python - 在 Tkinter 中更改标签和同时更改具有相同内部函数的变量有什么区别?
- pine-script - 使用变量设置直线的 x 点