Bug in shiny::updateCheckboxGroupInput()

If you want unselected all checkboxes defined using updateCheckboxGroupInput, the syntax should be:
updateCheckboxGroupInput(session, inputId, selected = NULL)

However, it does not work.
You must indicate again the parameter choices explicitly


Look at this code:

rm(list = ls())
library(shiny)

runApp(list(

  ui = basicPage(
    checkboxGroupInput('chkGrp', 
                       label="Choix", 
                       choices=list("A"="a", "B"="b", "C"="c", "D"="d", "E"="e")),
    actionButton("all","All"),
    actionButton("noneWithChoices","None With Choices"),
    actionButton("noneWithoutChoices","None Without Choices"),
    actionButton("partial","Partial"),
    verbatimTextOutput("value")
  ),
  server = function(input, output, session) {
    output$value <- renderPrint({ input$chkGrp })
    observe({
      if ( is.null(input$all) || input$all == 0)
        return()
      updateCheckboxGroupInput(session,"chkGrp", selected= letters[1:5] )
    })
    
    observe({
      if ( is.null(input$partial) || input$partial == 0)
        return()
      updateCheckboxGroupInput(session,"chkGrp", selected= c("a", "c") )
    })
    observe({
      if ( is.null(input$noneWithChoices) || input$noneWithChoices == 0)
        return()
      updateCheckboxGroupInput(session,"chkGrp", 
                               choices=list("A"="a", "B"="b", "C"="c", "D"="d", "E"="e"), 
                               selected=NULL)
    })
    observe({
      if ( is.null(input$noneWithoutChoices) || input$noneWithoutChoices == 0)
        return()
      updateCheckboxGroupInput(session,"chkGrp", 
                               selected=NULL)
    })
    
  }
))

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04