library(shiny)
ui = fluidPage( actionButton("loaddata","Load Data"), verbatimTextOutput("data"))
server = function(input,output){ rvs = reactiveValues(df = NULL) observeEvent(input$loaddata,{ # dummy code here - in reality this will be a piece of code that reads/generates some data rvs$df = data.frame(x=c(1,2,3),y = c("a","b","c")) showModal(modalDialog( title = "Important message", "Data has been loaded!" ))
})
output$data = renderPrint( head(rvs$df,20) )}
shinyApp(ui = ui, server = server)
ui = fluidPage( actionButton("loaddata","Load Data"), verbatimTextOutput("data"))
server = function(input,output){ df = eventReactive(input$loaddata,{ # dummy code here - in reality this will be a piece of code that reads/generates some data df = data.frame(x=c(1,2,3),y = c("a","b","c")) return(df) }) output$data = renderPrint( head(df(),20) )}
shinyApp(ui = ui, server = server)
ui = fluidPage( actionButton("loaddata", "Load Data"), verbatimTextOutput("data"))
server = function(input, output, session) { # step 1: load the data df = eventReactive(input$loaddata,{ data.frame(x=c(1,2,3),y = c("a","b","c")) }) # step 2: alert that data has been loaded observeEvent(df(), showModal(modalDialog( title = "Important message", "Data has been loaded!" )) ) # step 3: display the data (occurs at the same time as step 2) output$data = renderPrint( head(df(), 20) )}
shinyApp(ui = ui, server = server)