gpt4 book ai didi

r - R/光泽中的多项选择框-添加滚动条

转载 作者:行者123 更新时间:2023-12-04 08:55:46 27 4
gpt4 key购买 nike

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

)
))

服务器
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)
})

})

最佳答案

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

关于r - R/光泽中的多项选择框-添加滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15348385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com