Skip to content

Calling survfit within a function

2 messages · E. S. Venkatraman, Thomas Lumley

#
I have a function that generates data and tries to apply the survfit 
within it.  I have tried:

function(..){
x .....
survfit(Surv(tim,sts) ~ grp, data = x, envir = sys.frame(sys.parent()))
}

but I still get "Error: Object "x" not found".  Is there a fix?
(I use R-0.63.2 with the current survival4 package)

Thanks
E. S. Venkatraman
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 21 Jan 1999, Ennapadam Venkatraman wrote:

            
Are you using the new version in the devel directory?

I tried this and it worked:

R> ff<-function(){
+ dd<-data.frame(tt=1:10,ss=rep(1,10),xx=rep(0:1,5))
+ survfit(Surv(tt,ss)~xx,data=dd)
+ }
R>  ff()
Call: survfit(formula = Surv(tt, ss) ~ xx, data = dd)

Warning in min(..., na.rm = na.rm) : no finite arguments to min/max;
returning extreme.
Warning in min(..., na.rm = na.rm) : no finite arguments to min/max;
returning extreme.
     n events mean se(mean) median 0.95CI 0.95CI
xx=0 5      5    5     1.26      5      3    Inf
xx=1 5      5    6     1.26      6      4    Inf


Adding the envir= argument to survfit() doesn't have any effect and if it
did it would have the wrong effect -- you would be specifying the
environment as the parent of the calling frame.


	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._