我试图弄清楚如何在 Shiny 中使用 conditionalPanel
来根据 sliderInput
上选择的内容从 checkboxGroupInput
中删除选项。
下面是我的代码: ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("XXXXX"),
sidebarLayout(
sidebarPanel(
checkboxGroupInput("product.input", label = "Labels",
choices=c("Product A"="P1",
"Product B"="P2",
"Product C"="P3",
"Product D"="P4",
"Product E"="P5",
"Product F"="P6"),
selected=c("P1", "P2","P3","P4","P5","P6")),
sliderInput("prod.input",
label = "Select Month",
sep="",
min =1 , max = 12, value = c(5,8),step=1),
conditionalPanel(condition="prod.input<5",
checkboxGroupInput("product.input", label = "Labels",
choices=c("Product A"="P1",
"Product B"="P2",
"Product E"="P5",
"Product F"="P6")))),
mainPanel((tabsetPanel(
tabPanel("Table1",h2("Table Header"),tableOutput("figure"))))))))
服务器.R
shinyServer(function(input, output) {
output$figure <- renderPlot({
})
}
)
当 slider 输入小于5时,我希望“产品C”和“产品D”这两个复选框消失。当我使用条件面板时,会出现一个新列表,而不是更新相同的列表。任何有关我如何解决此问题的线索将不胜感激。
谢谢!
最佳答案
在我看来,您可以使用 updateCheckboxGroupInput
解决您的问题(请参阅 Shiny reference )。
关于r - conditionalPanel Shiny 隐藏复选框选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32060027/