9

Shiny is our internal BI tool. For our Shiny apps, we load data before shinyServer running:

load("afterProcessedData.RData") # or dt = fread("afterProcessedData.csv") shinyServer(function(input, output, session){ ... 

However, some of apps are loading big files and they take up to 30s to load up. Many users, when they open a page, don't know whether the page is broken since it is stuck when it is loading. They may close it or click filters, which may cause an error. In this case, a progress bar will be very helpful. I notice withProgress() may help but it has to be inside reactive() or renderXx().

One way I can do is to have laod() warpped with reactive() inside the shinyServer(function(input, output, session){ but my concern is it will slower the performance. And my users very care about the responsive performance.

Any suggestions for this situation?

Edit: I guess there is not an easy way to do this. I have another thought. Maybe I can show a text on the screen saying 'the data is loading', but I have to make it disappear after the first table gets show up. However, I don't know how to set up the condition. Below is my code showing first table:

dashboardBody( fluidRow( tabBox(width = 12, tabPanel("Summary", dataTableOutput("data1")), 

Thank you in advance!

5
  • Curious, why withProgress() inside a reactive () or render() a problem ? . Even though, I am not happy with the kind status bar it displays, but it works OK for me when I wrap withProgress in all my render() functions . Commented Feb 9, 2016 at 21:17
  • Additionally, how about wrap your data loading functions with examples shown in these SO solutions, and then render that out on Shiny withProgress() ? Commented Feb 9, 2016 at 21:21
  • This works for me. output$Ref_output <- DT::renderDataTable(withProgress( message = 'Processing the query', value = 5, expr = { DT::datatable(reference.table(), selection = 'multiple') With some changes to CSS file the progress bar is thicker and in red color than default one. Commented Feb 9, 2016 at 21:24
  • @user5249203 thanks for your answer. My concern of having load() in the reactive() is that it will slow down the performance since each change will call a load(). The second solution with SO solutions somehow makes load() 3 times longer, which will be blamed by clients. Commented Feb 9, 2016 at 21:42
  • If this load is in a global variable then why should it load at every session? for everything else you can and should use withProgress() also desable buttons while people wait with shinyjs package so they dont click on anything until its fully loaded Commented Feb 10, 2016 at 8:37

2 Answers 2

5

Even though I am still interested in knowing how to add process bar for load(), I have implemented the alternative solution, which is good for now. It has a text saying 'the data is loading...' on the page, and it will disappear after first table shows up.

#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...") ) ) 
Sign up to request clarification or add additional context in comments.

1 Comment

New aspects. Instead of loading the complete .rdata, you can save each object and read them separately. It is efficient and faster. Check readRDS . Now, there is an easy way to achieve spinner or likewise in Rshiny . DT::dataTableOutput(outputId = 'table')%>% withSpinner()
3

To reference the intriguing note from @user5249203 , withSpinner() looks to be a useful option for this functionality and is a part of the shinycssloaders package. I have not used myself, but it is definitely an intriguing package that happens to be on CRAN and to have some nice examples: https://andrewsali.shinyapps.io/example/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.