If I understand, you can try this:

DF <- data.frame(X = rep(1:3, each = 4), A = rnorm(12), B = rnorm(12))
aggregate(DF[,c("A", "B")], list(DF$X), mean)

On Tue, Jun 23, 2009 at 10: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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[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.

Reply via email to