title: R Shiny how to add 'select all' in checkbox within renderui
body: <p>I am using renderui in R Shiny to generate a checkbox, I'm wondering how to add a 'select all' option, which can be used to check and uncheck all the boxed.
  <a href="https://i.stack.imgur.com/sn4mJ.png" rel="nofollow noreferrer">here is an example of the checkbox I want</a></p>
  
  <p>This <a href="https://stackoverflow.com/questions/28829682/r-shiny-checkboxgroupinput-select-all-checkboxes-by-click">link</a> shows how to add the 'select all' button, but is not for the checkbox inside renderui. Currently the method I used is </p>
  
  <pre><code>  output$trmt_id &lt;- renderUI({
  
  if(is.null(ep_info())) {
    return() 
  }
  
  trmt_ids &lt;- unique(ep_info()$TRMT_ID)
  # add 'selected = ' to pre-select ctrl
  checkboxGroupInput("input_trmt_id", "Choose Treatment ID (Include Control)", choices = c(trmt_ids, 'All'))})
  
  
  observeEvent(input$input_trmt_id, {
  if (input$input_trmt_id %in% 'All') {
  
    updateCheckboxGroupInput(session, "input_trmt_id", "Choose Treatment ID (Include Control)", choices = c(unique(ep_info()$TRMT_ID), 'all'), selected = unique(ep_info()$TRMT_ID))
  }})
  </code></pre>
  
  <p>But the problem of this piece of code is user cannot unselect all boxed just by clicking 'all' again. </p>
  
  <p>Do you have some better ideas? Thanks in advance!</p>