[R] Temporarily turn off certain warnings
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Sat Mar 29 15:31:03 CET 2003
>From fixInNamespace, a new function in 1.7.0-to-be
if (bindingIsLocked(subx, ns)) {
unlockBinding(subx, ns)
assign(subx, x, env = ns)
w <- options("warn")
on.exit(options(w))
options(warn = -1)
lockBinding(subx, ns)
}
and if the function continues and you want warnings back on, you could do
w <- options("warn")
on.exit(options(w))
options(warn = -1)
lockBinding(subx, ns)
options(w)
on.exit()
On Sat, 29 Mar 2003, Damon Wischik wrote:
>
> 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.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list