在R/Shiny中的多项选择框 - 添加滚动条

12

我正在制作一个R/shiny网络应用程序。我想使用多选框(我使用了checkboxGroupInput(),但也接受其他选择)。然而,选择列表很长,我希望将其包含在一个相对较小的选项框中(一次显示5-6个选项),并使用滚动条滚动整个选项列表。

这个能做到吗? 最简示例:

ui.R

library(shiny)
choices = paste("A",1:30,sep="_")

shinyUI(pageWithSidebar(

# Application title
headerPanel("my title"),
sidebarPanel(   
  checkboxGroupInput("inp", "choose any of the following", choices)
),
mainPanel(
   tableOutput("result")

)
))

服务器.R

library(shiny)
shinyServer(function(input, output) {
myInput <- reactive({
    input$inp
})
output$result <- renderTable({
x = myInput()
if(length(x)==0) {
x = "No Choice Made"
}
matrix(x,ncol=1)
})

})
1个回答

10

我发现使用selectInput(..., multiple = TRUE)可以解决问题。


selectInput() 不具备复选框的功能。 - Lazarus Thurston
selectInput()checkboxGroupInput()是完全不同的小部件。这个答案怎么得到了+10分? - kraggle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接