[R] Using the 'by' function within a 'for' loop

2008-04-22 Thread Judith Flores
Dear R experts, I am sorry for sending this email again. I would imagine yesterday and maybe today, have been very busy days with the release of R v 2.7.0. I join all the R users who are very gratful for your contant work and efforts, specially knowing that you are doing this for the sake of

Re: [R] Using the 'by' function within a 'for' loop

2008-04-22 Thread hadley wickham
Hi Judith, Could you provide a copy of your data as well? (Either as a csv file, or by copying and pasting the output of dput(my.data.frame) or by generating a data.frame of random numbers with the same structure as your data). That will help people to see what your code does and suggest

Re: [R] Using the 'by' function within a 'for' loop

2008-04-22 Thread jim holtman
After talking about it, I forgot to put the drop=TRUE in the 'split' call: x.index - split(seq(nrow(dat)), dat[,c(tx,day)], drop=TRUE) results - lapply(x.index, function(.indx){ mn - mean(dat$k[.indx]) .. data.frame() }) On Tue, Apr 22, 2008 at 1:30 PM, Judith Flores [EMAIL

Re: [R] Using the 'by' function within a 'for' loop

2008-04-22 Thread jim holtman
One of the things that is probably happening is that the 'by' is producing all possible combinations and in some cases 'x' is size zero. Put a check in the function within the 'by' to check for this condition and just return a NULL. Another approach that I use is to split(seq(nrow(df),