Skip to content
Back to formatted view

Raw Message

Message-ID: <1350630125496-4646707.post@n4.nabble.com>
Date: 2012-10-19T07:02:05Z
From: Sando
Subject: Question about survdiff in  for-loop.

Hi everyone!!

I have dataset composed of a numbers of survival analyses. 
( for batch survival analyses by using for-loop) . 
Here are code !!

#######
dim(svsv)
Num_t<-dim(svsv)
Num<-Num_t[2]   # These are predictors !!

names=colnames(svsv)

for (i in 1:Num  )
{
name_tt=names[i]
survdiff(Surv(survival.m, survival) ~ names[i], data=svsv)
fit.Group<-survfit(Surv(survival.m, survival) ~ names[i] , data=svsv)
plot(fit.Group, col=2:1, xlab="Survival", ylab="Prob")
}

#####

names[i] is not working in the survdiff. 
According to help R , the predictor must be single subset. 

And, names[i] is also single character, I think. 

But, it do NOT work. 

How I can solve this problem ? 



Thank you. 

 




--
View this message in context: http://r.789695.n4.nabble.com/Question-about-survdiff-in-for-loop-tp4646707.html
Sent from the R help mailing list archive at Nabble.com.