I have an app where a large dataset is read in before the app starts. The app has separate ui and server files. So the UI is visible straightaway and the div for output plot remains empty. It sort of hangs for about 2-3 seconds as the data is read in. And then the plot is displayed. The rest of the app is fast enough and requires no progress bars. I would like to show some progress/indication that the data is being read in rather than just "freezing" for few seconds.
Here is a dummy example. The data is only read in once before the app loads. The data is used in ui as well as server.
library(shiny)
# read big file
#saveRDS(diamonds,"diamonds.Rds")
x <- readRDS("diamonds.Rds")
ui = fluidPage(
titlePanel("Progress bar test"),
selectInput("in_opts","Select",choices=colnames(x),selected=1),
verbatimTextOutput("out_txt")
)
server=function(input,output,session) {
output$out_txt <- renderPrint({
Sys.sleep(3)
head(x)
})
}
shinyApp(ui,server)
I have tried using shinycssloaders
. It generally works. It works well in this dummy example. But, it doesn't work for the "reading in file" part since that is outside the withSpinner()
function.
library(shiny)
library(shinycssloaders)
# read big file
#saveRDS(diamonds,"diamonds.Rds")
x <- readRDS("diamonds.Rds")
ui = fluidPage(
titlePanel("Progress bar test"),
selectInput("in_opts","Select",choices=colnames(x),selected=1),
shinycssloaders::withSpinner(verbatimTextOutput("out_txt"))
)
server=function(input,output,session) {
output$out_txt <- renderPrint({
Sys.sleep(3)
head(x)
})
}
shinyApp(ui,server)
Is there a way to display progress/indicator for the readRDS()
step?