r - conditionalPanel Shiny 隐藏复选框选项

标签 r shiny shinydashboard

我试图弄清楚如何在 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/

相关文章:

r - 使用 R 选择列中组内的前 N ​​个值

css - 调整 Shiny 进度条的大小并将其居中

javascript - 使用 JavaScript 使用 htmlOutput 元素作为导出的 PNG 文件的名称

r - 如何使用 sliderInput 在 R Shiny 中输入超过 2 个值

r - 在 ShinyDashboard 中的 menuSubItems 之间切换

python - 如何在 Rstudio 中调试 TensorFlow?

r - %*%+ 在矩阵运算中是什么意思?

r - 在Knitr中全局定义图形的控制参数

使用 Shiny 中的按钮重定向到选项卡

r - 如何正确使用 addResourcePath?