[R] Error in match.names(clabs, names(xi))

From: Quan Zhou <quan.poko2000_at_gmail.com>
Date: Tue, 05 Apr 2011 20:28:02 -0400


Hi Guys,
I have this part of a program:
library(survival)
Gastric <- cbind.data.frame(Gp=c(rep(1,45),rep(0,45)), ### 2nd gp 0

    time=c(1,63,105,129,182,216,250,262,301,301,342,354,356,358,     380,383, 383,388,394,408,460,489,499,523,524,535,562,569,675,676,

    748,778,786,797,955,968,1000,1245,1271,1420,1551,1694,2363,2754,2950,
    17,42,44,48,60,72,74,95,103,108,122,144,167,170,183,185,193,195,197,
    208,234,235,254,307,315,401,445,464,484,528,542,547,577,580,795,855,
    1366,1577,2060,2412,2486,2796,2802,2934,2988), Dth=c(rep(1,43),     0,0, rep(1,39), rep(0,6)))
CoxG0 <- coxph(Surv(time,Dth) ~ Gp, Gastric) srvGastA <- survfit(Surv(Gastric$time,Gastric$Dth)~1) ## 88 distinct times
#Gastric$time is all the time points either death or largest obervation
time.
#srvGastA$time is all the unique times

newGas <- data.frame(start=0, stop=1, Dth=1, Ploidy=1, tim=0)
#newGas <- r(0,1,1,1,0)

for (i in 2:90) {

    timind <- match(Gastric$time[i],srvGastA$time)     tmpmat <- array(0, dim=c(timind,5))#build an array with dim('index',5)

    tmpmat[,4] <- rep(Gastric[i,1], timind)#fourth column, return i's group
    tmpmat[timind,3] <- Gastric$Dth[i]
    tmpmat[,1] <- if(timind>1) c(0,srvGastA$time[1:(timind-1)]) else 0
    tmpmat[,2] <- srvGastA$time[1:timind]
    newGas <- rbind(newGas,tmpmat) }

I found when include "the last line" in the for loop. the error will jump out. But I do not know how to fix it. I initialize newGas without names. it does not work either....
It would be great if anyone knows how to fix the problem. Thanks a lot.
BR
Quan

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Apr 2011 - 00:30:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 02:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive