我有一个简单的闪亮应用程序:
#ui.r
navbarPage(
"Application",
tabPanel("General",
sidebarLayout(
sidebarPanel(
uiOutput("book1")
),
mainPanel(
uiOutput("book10")
)
)))
#server.
library(shiny)
library(DT)
server <- function(input, output,session) {
output$book1<-renderUI({
numericInput("bk1",
"Items in test",
value = 1,
min = 1)
})
output$book10<-renderUI({
selectInput("bk10",
"Select Items",
choices=1:10000,multiple =T,selected = 1)
})
}
在边栏中,我有一个numricInput()
,我想以此作为对限制在主面板selectInput()
中显示的选择数量的限制。例如,如果numericImput()
设置为5,则selectInput()
可能仅显示5个选项,例如:21,22,23,45,67。
答案 0 :(得分:1)
server <- function(input, output,session) {
output$book1<-renderUI({
numericInput("bk1",
"Items in test",
value = 1,
min = 1)
})
output$book10<-renderUI({
selectizeInput(
"bk10", "Max number of items to select", choices =1:1000,multiple =T,selected = 1,
options = list(maxItems = input$bk1))
#selectizeInput(
# "bk10", "Select Items", choices =1:1000,multiple =T,selected = 1,
# options = list(maxOptions = input$bk1))
})
}
有关更多选项,您可以选中here。希望对您有所帮助。