title: Shiny: keep boxes checked on datatable after changing inputs
body: <p>I want to implement checkboxes into my shiny app; however, I'm facing two problems: </p>
  
  <ol>
  <li>After I reorder columns, any checks on the datatable disappear (e.g., try to order table by <code>mpg</code>)</li>
  <li>After I remove column, any checks on the datatable disappear (e.g., unchecking boxes from <code>Columns to show:</code>)</li>
  </ol>
  
  <p>Here's my dummy example (it's a modified version of code from <a href="https://stackoverflow.com/a/26109468/1286528">this SO answer</a>):</p>
  
  <pre><code>library(shiny)
  TABLE = mtcars
  TABLE$id = 1:nrow(mtcars)
  APP &lt;- list()
  
  APP$ui &lt;- pageWithSidebar(
      headerPanel(NULL),
      sidebarPanel(
          checkboxGroupInput("show_vars", "Columns to show:", 
                             names(TABLE), selected = names(TABLE))
      ),
      mainPanel(
          dataTableOutput("resultTABLE")
      )
  )
  APP$server &lt;- function(input, output, session) {
  
      output$resultTABLE = renderDataTable({
          addCheckboxButtons &lt;- paste0('&lt;input type="checkbox" name="row', 
                                       TABLE$id, '" value="', TABLE$id, '"&gt;',"")
          cbind(Pick = addCheckboxButtons, TABLE[, input$show_vars, drop = FALSE])
      }, escape = FALSE)
  }
  
  runApp(APP)
  </code></pre>
  
  <p><code>APP</code> works, but for the full implementation I need to solve problems 1 and 2. </p>