我构建了一个 R/shiny 网络应用程序。我想要一个多选框(我使用 checkboxGroupInput(),但对替代方案持开放态度)。但是,选项列表很长,我想将它包含在一个相对较小的选项框中(一次显示 5-6 个选项),并带有一个滚动条,可以滚动整个选项列表。
有没有办法做到这一点?最小的例子:
用户界面
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)
})
})