Skip to content
Prev 43477 / 398506 Next

in which column is an entry?

Thanks, speed is sometimes reaaly important , but
to understand in a advanced practice guide about  loops.
i'm always not sure when indexing is necessary for the objects in the loop:
Different versions accept as function but didn'T run without error.

many thanks & regards,
christian

special <-  function(const,modeldat,YS) {
                  for(i in 1:10) {
const[i]=const[i]+1   #i'know  only here indexing make no sense!?
t1 <-  apply(YS,1, function(x) {  ifelse(all(is.na(x)) | all(na.omit(x)<0),
                                NA, which( x > const[i]))})
t1[is.na(t1)] <-  13
t2 <-  sapply(t1,function(x) { ifelse(x ==13,0,1)})
modeldat$MONTH <- t1
modeldat$ACTIVE <- t2
modeldats <- na.omit(modeldat)
mod1<-  coxph(Surv(MONTH,ACTIVE)  ~ ALTER+LEISTUNG,data=modeldats)
pdf(file = "~/Survival.pdf",    width = 6, height = 6, onefile = TRUE, family 
= "Helvetica",title = "R Graphics Output")
plot(survfit(mod1),ylim=c(.7,1),xlab='Month',ylab='Proportion not Active') }
                dev.off() }

Error in fitter(X, Y, strats, offset, init, control, weights = weights,  : 
	NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning message: 
Ran out of iterations and did not converge in: fitter(X, Y, strats, offset, 
init, control, weights = weights,  



Am Samstag, 31. Januar 2004 18:54 schrieben Sie: