[R] Remove warnings.
rkevinburton at charter.net
rkevinburton at charter.net
Tue Oct 14 14:59:39 CEST 2008
I have a function that could possibly generate warnings in a loop. What I want is to report the warnings (warnings()) then clear out the last.warning object so that if there is a call without warnings I will not see the previous warning.
Some example code:
generatewarning <- function(s)
{
warning(s)
}
loop <- function(f=TRUE)
{
if(f)
{
for(.index in 1:10)
{
if(.index %% 2)
{
generatewarning(sprintf("%d warning", .index))
}
}
}
}
loop()
warnings("TRUE")
loop(FALSE)
warnings("FALSE")
loop()
warnings("TRUE")
Notice that the call to "warnings("FALSE")" still reports the warnings from the previousely generated warnings. I want to "clear" this set since it has already been reported. Is there a way to do this?
Thank you.
Kevin
More information about the R-help
mailing list