title: Is it possible to update and output a shiny table as it's being generated?
body: <p>I am currently working on a shiny app that runs a series of calculations on a dataset on the fly when someone presses &quot;Calculate&quot;. The dataset is very large and a lot of calculations are made via a <code>lapply</code>, which allows the user to track the progress with a progress bar.</p>
  <p>This means the generation of the output data frame can be quite slow even when there are potentially results already sitting there just waiting to be displayed. The problem I'm having is that the data is potentially quite time sensitive when something is found and therefore if the calculations take, say, 15 minutes to run, there may have been something to display on the first calculation that is 15 minutes out of date.</p>
  <p>Is there a way that after each iteration of the <code>lapply</code> (or feel free to suggest another method) the app can look to see whether there is data there and immediately show it, essentially refreshing the output table after each iteration? Essentially updating the reactive value during the observe rather than after.</p>
  <p>I've put below a short example app that may help visualise the problem I'm having:</p>
  <pre><code>library(shiny)
  
  testDF &lt;- data.frame(number = c(1:10),
                       letter = letters[1:10])
  
  ui &lt;- fluidPage(
      # UI Input
      numericInput(inputId = &quot;attemptDivide&quot;, label = &quot;Number to divide by&quot;,
                   value = 1, min = 1, max = 10),
  
      actionButton(inputId = &quot;calculate&quot;, label = &quot;Calculate&quot;),
  
      # UI Output
      dataTableOutput(&quot;dividedTable&quot;)
  
  )
  
  # Define server logic
  server &lt;- function(input, output) {
  
      # Create a bucket for results
      results &lt;- reactiveVal()
  
      # Observe when &quot;Calculate&quot; is pushed and we should work out whether the
      # number is perfectly divisible by the input given
      observeEvent(input$calculate, {
  
          divisibleDF &lt;- lapply(testDF$number, function(x) {
  
              # Set to sleep for 1 second to simulate for the the lapply being
              # bigger and taking more time than this example
              Sys.sleep(1)
  
              # Find the row we're interested in
              interest &lt;- subset(testDF, number == x)
  
              # Find whether the number is perfectly divisible by the one given
              divisible &lt;- (x / input$attemptDivide) %% 1 == 0
  
              # If divisible is TRUE we keep, else we return an empty data frame
              if (divisible) {
                  return(interest)
              } else {
                  return(data.frame(number = integer(), letter = character()))
              }
  
          }) %&gt;%
              do.call(rbind, .)
  
          # Save the results to bucket
          results(divisibleDF)
  
      })
  
      # Create the table
      output$dividedTable &lt;- renderDataTable({
          results()
      })
  
  }
  
  # Run the app
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>Thanks in advance for any help.</p>