How to change warning setting?

VincentH picture VincentH · Jun 28, 2012 · Viewed 13k times · Source

I am trying to debug a function. I would like to display warnings when they occur but I don't understand how to change the warning settings.

Answer

Ben Bolker picture Ben Bolker · Jun 28, 2012

It may be useful to specify

options(warn=2, error=recover)

As mentioned by @plannapus, warn=2 will upgrade warnings to errors; error=recover will drop you into a debug/browser mode at the point where the warning (now upgraded to an error) occurred. (Use options(warn=0, error=NULL) to restore the original settings.)