title: How to replaceData in DT rendered in R shiny using the datatable function
body: <p>I have an <code>R</code> <code>shiny</code> app with a <code>DT</code> <code>datatable</code> that is rendered using the <code>datatable</code> function in order to set various options. I would like to use <code>dataTableProxy</code> and <code>replaceData</code> to update the data in the table, but all the examples I can find assume the <code>DT</code> is rendered directly from the data object, not using the <code>datatable</code> function. The reprex below shows what I would like to do, but <code>replaceData</code> doesn't work in this pattern. How do I do this? Thanks.</p>
  
  <pre><code>
  # based on 
  # https://community.rstudio.com/t/reorder-data-table-with-seleceted-rows-first/4254
  
  library(shiny)
  library(DT)
  
  ui = fluidPage(
      actionButton("button1", "Randomize"),
      fluidRow(
          column(6,
                 h4("Works"),
                 DT::dataTableOutput('table1', width="90%")),
          column(6,
                 h4("Doesn't Work"),
                 DT::dataTableOutput('table2', width="90%"))
      )
  )
  
  server = function(input, output, session) {
  
          my &lt;- reactiveValues(data = iris)
  
          output$table1 &lt;- DT::renderDataTable(isolate(my$data))
  
          output$table2 &lt;- DT::renderDataTable({
              DT::datatable(isolate(my$data),
                            options = list(lengthChange=FALSE, ordering=FALSE, searching=FALSE,
                                         columnDefs=list(list(className='dt-center', targets="_all")),
                                         stateSave=TRUE, info=FALSE),
                            class = "nowrap cell-border hover stripe",
                            rownames = FALSE,
                            editable = FALSE
              ) %&gt;%
                  DT::formatStyle('Sepal.Width', `text-align`="center")
          })
  
          observeEvent(input$button1, {
  
              # calculate new row order
              row_order &lt;- sample(1:nrow(my$data))
              my$data &lt;- my$data[row_order, ]
  
              proxy1 &lt;- DT::dataTableProxy('table1')
              DT::replaceData(proxy1, my$data)
              proxy2 &lt;- DT::dataTableProxy('table2')
              DT::replaceData(proxy2, my$data)
  
          })
  
  }
  
  shinyApp(ui, server)
  </code></pre>