【问题标题】:How can I change R-Shiny "checkboxinput" value to FALSE/TRUE programmatically?如何以编程方式将 R-Shiny “checkboxinput” 值更改为 FALSE/TRUE?
【发布时间】:2019-06-29 21:00:40
【问题描述】:

我想在运行时将复选框输入值更改为 FALSE/TRUE。我该怎么做?

checkboxInput(inputId = "smoother", label = "Overlay smooth trend line", value = FALSE)

【问题讨论】:

    标签: r checkbox shiny


    【解决方案1】:

    您可以使用updateCheckboxInput()。请参阅下面的示例:

    可重现的例子:

    library(shiny)
    ui <- fluidPage(
      actionButton(
        inputId = "check",
        label = "update checkbox"
      ),
      checkboxInput(
        inputId =  "checkbox", 
        label = "Input checkbox"
      )
    )
    
    server <- function(input, output, session) {
      observeEvent(
        eventExpr = input$check, {
          updatedValue = !input$checkbox
    
          updateCheckboxInput(
            session =  session,
            inputId =  "checkbox", 
            value = updatedValue
          )
        }
      )
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 2013-11-15
      • 1970-01-01
      • 2019-10-17
      • 2017-11-05
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      相关资源
      最近更新 更多