Skip to content

options()$warn==2 and try() (PR#1570)

2 messages · Thomas Lumley

#
In fact the warning that the convergence may not have been reached in
coxph is usually spurious, so you probably don't want to catch it.
However, there does seem to be something strange going on.


Simplified version
 f<-function(){
    x<-try(warning("a"))
    y<-try(warning("b"))
    list(x,y)
 }
Error in try(warning("a")) : (converted from warning) a
[[1]]
[1] "Error in try(warning(\"a\")) : (converted from warning) a\n"
attr(,"class")
[1] "try-error"

[[2]]
[1] "b"
[[1]]
[1] "a"

[[2]]
[1] "b"


Or even more simply
Error in try(warning("Danger, Will Robinson")) :
        (converted from warning) Danger, Will Robinson
Error in warnings() : Object "last.warning" not found
Error in try(warning("Danger, Will Robinson")) :
        (converted from warning) Danger, Will Robinson
-thomas
Thomas Lumley			Asst. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Even try() isn't really involved.

The problem is in src/errors.c:warningcall

It sets a flag inWarning, presumably to ensure that infinite loops of
recursive warnings don't happen, but if options(warn)==2 then an error is
signalled and the flag is not cleared until the next error.

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._