[R] Detect the Warning Message

jim holtman jholtman at gmail.com
Fri Nov 5 13:26:32 CET 2010


?options

and then you will find the following:

warn:
sets the handling of warning messages. If warn is negative all
warnings are ignored. If warn is zero (the default) warnings are
stored until the top–level function returns. If fewer than 10 warnings
were signalled they will be printed otherwise a message saying how
many (max 50) were signalled. An object called last.warning is created
and can be printed through the function warnings. If warn is one,
warnings are printed as they occur. If warn is two or larger all
warnings are turned into errors.


by setting

options(warn = 2)

will cause the system to halt at that point.  Also setting:

options(error=utils::recover)

will drop you in the 'browser' (?browser) so you can see the values of
objects when the error occurred.

Google for 'debugging R' to get some more information.

On Fri, Nov 5, 2010 at 4:00 AM, Yen Lee <b88207001 at ntu.edu.tw> wrote:
> Dear all,
>
>
>
> I've written a function and repeated it for 5000 times with loops with
> different value, and the messages returned are the output I set and 15
> warnings.
>
> I would like to trace the warnings by stopping the loop when warning came
> out.
>
> Does anyone know how to make it?
>
>
>
> Thanks a lot for your help.
>
>
>
> Yen
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list