[R] survfit

Thomas Lumley tlumley at u.washington.edu
Mon Feb 26 22:42:38 CET 2001


On Mon, 26 Feb 2001, gb wrote:

> I have two problems with 'survfit' in survival5; R-1.2.1, RH7.0:
> ------------------------------------------------------------
> > ls()
> character(0)
> > tid <- c(1,2,3)
> > eve <- c(1,1,1)
> > x <- c(1,0,1)
> > library(survival5)
> > fit <- coxph(Surv(tid, eve) ~ x)
> > s.fit <- survfit(fit)
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames,  :
> 	variable lengths differ
> -------------------------------------------------------------
> Putting these statements in a function generates on the other hand:
> 'Error in Surv(tid, cens) : Object "cens" not found'
> (from survfit) when executing the function.
>
> What am I doing wrong?

There seems to be a problem with model.frame.coxph() and the (relatively)
new behaviour of model.frame using the environments of formulas. The
environment of a formula in a coxph() object is something strange.

A temporary work-around  is to always put your data in a dataframe.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list