title: R Shiny dynamic DT Datatable remember filters/sorting
body: <p>I'm building a <code>R Shiny</code> app with a dynamic datatable, using the <code>DT</code> package. Users are able to select two columns within a data.frame that contains more columns.</p>
  
  <p>When users select a column, the datatable is updated and all filters/sorting are reset to default within the datatable object. How can I let the application remember filters and sorting when the given column is not replaced by the user? </p>
  
  <p>Minimal working example below:</p>
  
  <pre><code>library(shiny)
  library(DT)
  library(data.table)
  
  
  server &lt;- function(input, output) {
  
    df &lt;- data.frame(
      name = rep('a',20),
      dimA = 1:20,
      dimB = 21:40,
      dimC = 41:60
    )
  
    observe({
      columns &lt;- c('name', input$dim1ID, input$dim2ID)
      dfDt &lt;- df[names(df) %in% columns]
  
      output$dtDataTable = DT::renderDataTable(
        server = FALSE,
  
        expr = datatable(
          dfDt,
          filter = 'top',
          rownames = FALSE,
          selection = 'none',
          options = list(sDom  = '&lt;"top"&gt;rt&lt;"bottom"&gt;ip')
        )
      )
    })
  }
  
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
        ## Dimension 1
        selectInput(
          inputId = "dim1ID",
          label = "Dimensie 1",
          choices = c('dimA', 'dimB', 'dimC'),
          selected = 'dimA'
        ),
        ## Dimension 2      
        selectInput(
          inputId = "dim2ID",
          label = "Dimensie 2",
          choices = c('dimA', 'dimB', 'dimC'),
          selected = 'dimB'
        )
      ),
      mainPanel(DT::dataTableOutput('dtDataTable'))
    )
  )
  
  shinyApp(ui = ui, server = server)
  </code></pre>