> Hi everyone!!
> I have dataset composed of a numbers of survival analyses.
> ( for batch survival analyses by using for-loop) .
> Here are code !!
> Num<-Num_t # These are predictors !!
> for (i in 1:Num )
> 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.
That's a problem with how formulas are parsed: you are effectively
telling survdiff() that you want names[i] as your predictor variable,
when actually you want it as the name of your predictor variable.
Using svsv[i] rather than names[i] should work. Or you can insert the
value of names[i] into the formula with