[R] Temporarily turn off certain warnings

Damon Wischik djw1005 at cam.ac.uk
Sat Mar 29 15:18:28 CET 2003


When I call, for example
> min()
> min(Inf,Inf)
I get the warning: "no finite arguments to min; returning Inf".

When I make such a call, it is usually intentionally. I would like to turn
off those warnings, so they don't hide other (usually more serious)
warnings. (I like to debug my programs with options(warn=2).)

How can I write a function which does the same as min but doesn't generate
these warnings? I wrote my own version of min, but I'm not confident it
deals properly with all the structures that min deals with. So what I'd
like to know is how I can turn off a specific warning in a specific block
of code. I looked at try, but it seems to deal with errors rather than
warnings.

Damon Wischik.



More information about the R-help mailing list