[R] worked in R, but not in S-Plus

array chip arrayprofile at yahoo.com
Wed Nov 10 01:50:09 CET 2004


Hi, 

I wrote a function that worked well in R, but not in
S-Plus, can anyone suggest a solution?

> f.coxph.zph<-function(x)
{
	cox.fit <- coxph(Surv(time.cox, status.cox) ~ x,
na.action = na.exclude, method = "breslow")
	fit.zph<-cox.zph(cox.fit,transform='log')
	fit.zph$table[,3]
}

yyy is my data frame that contains survial time,
censor status and predictor variables.

> time.cox<-yyy$time
> status.cox<-yyy$status
> apply(yyy[,-(1:2)],2,f.coxph.zph)

When run in S-Plus, it gave the following error
message:

Problem in model.frame.coxph(fit): Object "x" not
found

If I remove the 2nd and 3rd lines inside the function,
it worked, so definitely something is wrong in passing
the coxph object into the cox.zph().

Thanks




More information about the R-help mailing list