[R] Error in if (!length(fname) || !any(fname == zname)) { :

Frank E Harrell Jr f.harrell at vanderbilt.edu
Fri May 4 16:08:52 CEST 2007


hongyuan cao wrote:
> Dear R users,
> 
> I tried to fit a cox proportional hazard model to get estimation of stratified survival probability. my R code is as follows:
> 
> cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] +colon[,20]+colon[,9], surv=TRUE)
> Error in if (!length(fname) || !any(fname == zname)) { : 
>         missing value where TRUE/FALSE needed
> Here colon[,13] is the one that I want to stratify and the others are all coefficients. How can I solve this problem?  Thanks a lot!!!!!
> 
> Grace

The Design package does not like you to have complex variable names like 
that, and in general storing your data in a matrix when you want to 
treat columns as separate variables is not the best approach.  I would 
use something like

S <- with(d, Surv(  ) )   # d = data frame
h <- as.data.frame(colon)  # assumes colon is a matrix;make sure it had 
column names
cph(S ~ strat(v1)+v2+v3+v4, data=h)

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list