[R] tracing the origin of warning messages

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon May 3 10:50:23 CEST 2010


Use options(warn=2)

Uwe Ligges


On 03.05.2010 08:55, Thomas Wutzler wrote:
> Dear R Users,
>
> what is the best way to trace the origin of warning messages?
>
> If an error occurs I can use traceback() to see where it comes from. I
> would like to do similar investigation, where a warning message
> originates from.
> Is there an option to turn warnings to errors?
>
> I tried the following
>> fWarn<- function(){ warning("A") }
>> options(warning.expression = stop())
>> fWarn()
>> traceback()
> 2: stop()
> 1: options(warning.expression = stop())
>
> Hence, it does not give me the desired stack trace and the information
> that the warning occured in function fWarn, so far.
>
> (using Windows XP, R version 2.10.1)
>
> Best regards
> Thomas Wutzler
>
> ______________________________________________
> 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.



More information about the R-help mailing list