From tlumley@u.washington.edu  Fri May 17 22:04:27 2002
From: tlumley@u.washington.edu (tlumley@u.washington.edu)
Date: Fri, 17 May 2002 23:04:27 +0200 (MET DST)
Subject: [Rd] Re: [R] options()$warn==2 and try() (PR#1570)
Message-ID: <200205172104.XAA22116@pubhealth.ku.dk>

>
> 	I have a function called FitModels(), which simply takes in the
> names of a data.frame and two variable names within that data.frame, and
> fits and returns a list of objects from 2 coxph() fits, one main effects and
> one interaction model.  Sometimes the two variables are such that there is a
> warning message: convergence has not been reached, or the X matrix is
> singular, or some such.

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)
 }

> options(warn=2)
> f()
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"

> f()
[[1]]
[1] "a"

[[2]]
[1] "b"


Or even more simply

> options(warn=2)
> try(warning("Danger, Will Robinson"))
Error in try(warning("Danger, Will Robinson")) :
        (converted from warning) Danger, Will Robinson
> try(warning("Danger, Will Robinson"))
> try(warning("Danger, Will Robinson"))
> warnings()
Error in warnings() : Object "last.warning" not found
> try(warning("Danger, Will Robinson"))
Error in try(warning("Danger, Will Robinson")) :
        (converted from warning) Danger, Will Robinson
> try(warning("Danger, Will Robinson"))
> try(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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Re: [R] options()$warn==2 and try() (PR#1570)
tlumley@u.washington.edu