【发布时间】:2018-11-08 11:00:10
【问题描述】:
我必须为同一个变量使用多个选择输入。当我选择一个类别 bla1 时,该类别应排除在 bla2 中。我该如何存档?是否有链接两个 selectizeinputs 的选项?
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
selectizeInput("bla1", "muh", choices = faithful$waiting, multiple = TRUE),
selectizeInput("bla2", "muh2", choices = faithful$waiting, multiple = TRUE)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
【问题讨论】:
-
您必须通过
renderUI在服务器中创建selectizeInput并包含一些过滤逻辑。