Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny: preventing initial error messages in endpoints while conductor executes

Tags:

r

shiny

I am building my first Shiny app - you can access the live version here: http://justmytwospence.shinyapps.io/StepLively/

It works fine, but you can probably see my problem as soon as you load the page. All of hte outputs hinge on a reactive conductor that takes a while to execute (its the function that actually performs a step-wise regression). Therefore, my outputs display error messages until the reactive conductor finishes executing. This only takes a few seconds, but it very annoying and unpolished.

Is there a way to schedule the execution of the reactive endpoints so that they don't execute until the reactive conductor has finished? Alternatively- but less favorably- is there a way to test for the availability of the reactive conductor and display something else when it is not available. Something along the lines of if (reactive_conductor_function()) {blah}. That won't work, however, because its a function.

Edit: I added an "Execute" button to completely bypass this issue, so its not evident in the app at the moment.

like image 515
Spencer Boucher Avatar asked Oct 30 '13 03:10

Spencer Boucher


1 Answers

You could try something like:

if(is.null(reactive_conductor_function()){return(NULL)}
#rest of your code follows

or

reactive_data <- reactive_conductor_function()
if(is.null(reactive_data)){return(NULL)}
#rest of your code follows

Both of these will prevent anything downstream in that code block from happening until after the reactive_conductor_function has data. I'm not sure on the first one, but I frequently use the second version of this code.

I would be able to give better advice if you could post some code examples!

like image 83
JClarke09 Avatar answered Oct 20 '22 20:10

JClarke09