Skip to content
Prev 212377 / 398500 Next

Odp: Loop overwrite and data output problems

Hi

r-help-bounces at r-project.org napsal dne 01.03.2010 16:36:27:
the
family="binomial")
be
out
I
Well, I am still a bit unsure what is your problem. You used slower way 
but i believe you should use quicker one as you want to cycle it 100 times

Assuming your data are named data

dat.o<-data[order(data$ID2),]
len<-rle(dat.o$ID2)$lengths
shift.len<-c(0,cumsum(len))[-(length(len)+1)]

# declare object for storing your results (the structure depends on 
structure of the result)
mod<- vector(10, mode="list")

for(i in 1:10) {
samp<-sapply(lapply(split(dat.o$ID2, dat.o$ID2), function(x) 1:length(x)), 
sample, 1)
Sample.dat <- dat.o[shift.len+samp,]


# do any of your stuff here (put Sample.dat instead of res)

m1.R<-glm(cbind(res$BEH_T, res$BEH_F) ~ res$SITE + res$YEAR + 
res$PRECIP_MM_DAY + res$PUP_AGE_EST + res$MO_AIR_TEMP, family="binomial")
mod[[i]]<-dredge(m1.R)

}

then you shall get a list with 10 components each one for one result.
You can extract each component acccordingly

mod[[1]]

Regards
Petr
http://n4.nabble.com/Loop-overwrite-and-data-
http://www.R-project.org/posting-guide.html