R/shiny中的多选框 - 添加滚动条

ami*_*mit 10 r shiny

我构建了一个R /闪亮的Web应用程序.我想要一个多选框(我使用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")

)
))
Run Code Online (Sandbox Code Playgroud)

server.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)
})

})
Run Code Online (Sandbox Code Playgroud)

ami*_*mit 10

我发现使用selectInput(..., multiple = TRUE)诀窍.