DT::renderDataTable dynamic update

I would like to create a table from a data.frame using DT::renderDataTable

When the data.frame is updated elsewhere in my code, I would like to re-render the table.

Could someone please provide some guidance on how to proceed?

Thanks

...

This is usually achieved by making your data frame reactive. Simple example below.

library(shiny)

ui <- fluidPage(
  numericInput("nrows", "Number of rows", value = 5, min = 1, max = 100),
  dataTableOutput("data")
)

server <- function(input, output, session) {
  data <- reactive({
    req(input$nrows)
    x <- rnorm(n = input$nrows)
    data.frame(x = x)
  })
  output$data <- renderDataTable({
    data()
  })
}

shinyApp(ui = ui, server = server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.