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)