[R] Loop overwrite and data output problems
RCulloch
ross.culloch at dur.ac.uk
Mon Mar 1 11:34:18 CET 2010
HI Ivan, thanks for your post, I really appreciate the time you've taken over
my problem!
if (I==1) Sample.dat<-tmp[sample(1:max,1),] else {
Sample.dat<-rbind(Sample.dat,tmp[sample(1:max,1),])
This part of the script works - I appreciate that it may not be the best
option and I'm perhaps papering over the cracks but I did try your method
and it didn't seem to work - but I am 100% sure that it is my fault! Most
likely due to the Sample.dat <-list() ) command you suggest - not sure if
you mean Sample.dat <-list(ALL.R[1,]) )? But that doesn't work.
It seems like you have the correct answer though, with respect to the 'store
your line in the Ith element of the list' comment which is exactly what I
want to do. So after the model:
m1.R<-glm(cbind(Sample.dat$BEH_T, Sample.dat$BEH_F) ~ Sample.dat$SITE +
Sample.dat$YEAR + Sample.dat$PRECIP_MM_DAY + Sample.dat$PUP_AGE_EST +
Sample.dat$MO_AIR_TEMP, family="binomial")
mod<-dredge(m1.R)
I want to do a similar command that will store the first line for each model
output - but when I use similar if and else commands I can't get it to work,
they just overwrite the data because I can't see where to set the variable
to avoid this, for example, I want to take mod[1,] so I could follow the
above script with:
Line<-mod[1,]
if (S==1) Line else {Line<-rbind(Line, mod)}
but because I can't work out where to place the loop what obviously happens
is that Line is overwritten on every loop resulting in the data overwriting
itself,
Sorry, I appreciate that I'm not explaining this very well.
Best wishes,
Ross
--
View this message in context: http://n4.nabble.com/Loop-overwrite-and-data-output-problems-tp1570593p1573391.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list