You can add an argument ignoreNull = FALSEto eventReactive. The following is a working example. Hope this helps!
shinyApp(ui,server)
library(shiny)
ui <- fluidPage(
actionButton('refreshData','Refresh!'),
tableOutput('summaryTable')
)
server <- function(input, output, session){
df = eventReactive (input$refreshData, ignoreNULL = F, {
mtcars[sample(seq(nrow(mtcars)),5),]
})
output$summaryTable = renderTable({
head(df())
})
}
shinyApp(ui,server)
Compare this to application behavior where the argument is ignoreNullnot used:
library(shiny)
ui <- fluidPage(
actionButton('refreshData','Refresh!'),
tableOutput('summaryTable')
)
server <- function(input, output, session){
df = eventReactive (input$refreshData, {
mtcars[sample(seq(nrow(mtcars)),5),]
})
output$summaryTable = renderTable({
head(df())
})
}
source
share