On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote:
Here is a method that I use in this situation. I work with the indices of the rows so that copies are not made and it is fast.
Result <- lapply(split(seq(nrow(df)), df$a), function(.a){ # partition on the first variable lapply(split(.a, df$z[.a]), function(.z){ # partition on the second variable -- notice the subsetting c(quantile(df$r[.z]), ...anything else you want to compute) }) }) Result <- do.call('rbind', Result) # create a matrix - now you have your results
Jim
Jim,
Thank you for your reply. For some reason, when I try your proposed solution I get:
Error in sort(unique.default(x), na.last = TRUE) :
`x' must be atomicEventually, I used the solution proposed by Gabor G in this thread. One advantage of his solution is that it is easier to scale up I believe; for example in the case you have 3 factors that together subset the data frame.
Regards, Itay
---------------------------------------------------------------- [EMAIL PROTECTED] / +1 (206) 543 9040 / U of Washington
______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
