search for: generatewarning

Displaying 1 result from an estimated 1 matches for "generatewarning".

2008 Oct 14
1
Remove warnings.
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&quot...