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

______________________________________________
R-help@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.

Reply via email to