title: R Shiny: automatically refreshing a main panel without using a refresh button
body: <p>I have a Shiny app with multiple <code>actionButton</code> commands.  When I click each button individually (e.g., to plot a graph or render a table), I would like my main panel to automatically update/refresh with the corresponding graph or table.  Instead, my Shiny app simply appends the output of one <code>actionButton</code> to the previous output of the other <code>actionButton</code> within the same panel.  </p>
  
  <p>From previous Stack Overflow posts, it seems that the only way around this problem is to implement a refresh button.  For instance, in the following MWE:</p>
  
  <pre><code>library(DT)
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
        selectInput("amountTable", "Amount Tables", 1:10),
        actionButton("submit1" ,"Submit", icon("refresh"),
                     class = "btn btn-primary"),
  
        actionButton("refresh1" ,"Refresh", icon("refresh"),
                     class = "btn btn-primary")
  
      ),
      mainPanel(
        # UI output
        uiOutput("dt")
      )
    )
  )
  
  server &lt;-  function(input, output, session) {
  
    global &lt;- reactiveValues(refresh = FALSE)
  
    observe({
      if(input$refresh1) isolate(global$refresh &lt;- TRUE)
    })
  
    observe({
      if(input$submit1) isolate(global$refresh &lt;- FALSE)
    })
  
    observeEvent(input$submit1, {
      lapply(1:input$amountTable, function(amtTable) {
        output[[paste0('T', amtTable)]] &lt;- DT::renderDataTable({
          iris[1:amtTable, ]
        })
      })
    })
  
    output$dt &lt;- renderUI({
      if(global$refresh) return()
      tagList(lapply(1:10, function(i) {
        dataTableOutput(paste0('T', i))
      }))
    })
  
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>Source: <a href="https://stackoverflow.com/a/43522607">https://stackoverflow.com/a/43522607</a></p>
  
  <p>You need to click on the refresh button in order to clear the previous output before displaying a new output, otherwise they will stack on top of each other.  </p>
  
  <p>Is there a way to dynamically/reactively refresh a main panel without explicitly clicking on a refresh button?  For instance, it would be nice to click on a new <code>actionButton</code> button to display the next output and have it auto-refresh the main panel at the same time.  Please feel free to supply your own MWE to show how this process could work.  </p>