try: dfr <- data.frame(A=rnorm(50), B=runif(50), X=factor(sample(c('L1','L2'),50,repl=TRUE)))
by(dfr[, 1:2], dfr$X, mean) hth, Kingsford Jones On Tue, Jun 23, 2009 at 7:57 PM, R_help Help<rhelp...@gmail.com> wrote: > Hi, > > To set a simple an clear picture of what I'd like to do, here is an example. > I would like to calculate mean of column A and B bucketed by factor in > column X in a data.frame. lapply or aggregate operates on a single column. I > found dapply function in some package which doesn't seem to exist any more. > > Is there anyway that I can accomplish something like this? Thank you so much > in advance. > > adschai > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.