Export Error/Warning Messages from R console?

609 views
Skip to first unread message

YL

unread,
Feb 5, 2016, 11:11:50 AM2/5/16
to Shiny - Web Framework for R
Hi Joe and other Shiny developers, 

I have a question about how to export errors for Shiny app. Let's say I have an app doing mixed effect model, and drawing the fitted population mean plot in Shiny. When there are errors regarding the model fit (e.g., model cannot converge), we see relevant error or warning messages in R console. 

However, when it comes to Shiny, there is no plot generated. We will have to go back to R console in order to check if there is something wrong, which is totally fine for developers. But for users, they may be very confused with regard to why no plot showing up in Shiny.

Therefore, is there a good way to export some error/warning messages? 
(so generally, I want some 'important' error/warning messages, not ALL of them (printed in R console); In addition, we can either export the messages in Shiny or store them as a log in a temporary directory).

Any insight will be highly appreciated! Thank you.

Joe Cheng

unread,
Feb 5, 2016, 5:47:45 PM2/5/16
to YL, Shiny - Web Framework for R
Well an error ought to show up in Shiny, usually in bold red letters. You can try this by calling stop("boom!") from within a renderPlot, for example.

For warnings, they get printed to the console (and in Shiny server, a log file) but nothing else. You can change the handling yourself using either options(warn=[number]) to turn a warning to an error (see ?options for details) or you can use tryCatch/withCallingHandlers to do something else with warnings. http://adv-r.had.co.nz/Exceptions-Debugging.html You will still need some way of passing the message to the user; we don't have this as a feature of Shiny yet, maybe someone knows of an extension that lets you do this? Maybe in shinyjs?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/5afaf551-6bbc-4add-b1bf-9d3aeac97e94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

YL

unread,
Feb 8, 2016, 11:31:13 AM2/8/16
to Shiny - Web Framework for R, liy...@gene.com
Hi Joe, 

Thank you for your reply. 

I understand that any error messages will show up in Shiny (in bold red letters). However, some of them are not of interest. For example, when we create uiOutput(s) for users to select variables, I notice that there is often an error message saying 'Error: undefined columns selected' (before this variable gets selected). We do NOT want this type of error to show up to users; rather, we just want to show the modeling errors. I know that we can completely turn off error messages by specifying
tags$style(type = "text/css",
           ".shiny-output-error { visibility: hidden; }",
           ".shiny-output-error:before { visibility: hidden; }")                                                                                              

This will suppress ALL the error messages including any possible ones from modeling/analysis. Therefore, I wonder is there a way to control which error messages to show, and which to not show? Or alternatively, turn off error message for some pages, but turn it back on when needed (like, .shiny-output-error {visibility: show;} or something similar)? 

Sorry if this question seems to be dumb. but yea thank you so much!

Joe Cheng

unread,
Feb 8, 2016, 2:24:50 PM2/8/16
to YL, Shiny - Web Framework for R
You shouldn't ignore those warnings, but rather endeavor to make them go away. In the case of missing inputs, use the req() function to abort processing cleanly: http://shiny.rstudio.com/articles/req.html

Reply all
Reply to author
Forward
0 new messages