Z. Zhang
Z. Zhang

Reputation: 501

R Shiny displays 'loading' while rendering table

My question is really similar to below:

R shiny: display “loading…” message while table is being rendered

Sorry I don't have enough reputation to comment it so I create a new question. My Shiny page has a renderGvis() and a renderDataTable() to display a graph and a table. Because it has to load() a 5 million rows table first, it takes a while to show up. And I have to have something to show it is loading, otherwise the users might leave. I found above post very useful but the loading message disappear too fast. The gap between it disappears and the table shows up is about 20s.

Before I saw above post, I did try below methodology:

#server.R   firstData is a reactive function to get the data for 1st table
output$firstTable = reactive({
return(is.null(firstData()))
})
#ui.R
  conditionalPanel(
      condition = "output.firstTable",
      box(width = 12,
              h1("The data is loading..."))) 

However, it also disappears too fast. And I don't know the reason. Does anyone have any suggestions?

Thank you in advance.

Upvotes: 0

Views: 2924

Answers (1)

vck
vck

Reputation: 837

You may interested in withProgress i used this method in several app for big data loadings and long computations.

I used data loading in server function as:

stockdata<-withProgress(expr = {readRDS("sample.RDS")}
                        ,message = "Loading... Please wait")

http://shiny.rstudio.com/articles/progress.html

Upvotes: 2

Related Questions