Wendy,

Depending on what you want i.e. row based summing or summing the whole colum
you should sue colSum or sum as for FUN.

You can probably achieve what you want with something like this:
> t <- by(t(test), INDICES=list(colnames(test)), FUN=colSums, simplify=TRUE)
> t
: A
V1 V2 V3
 5  7  9
---------------------------------------------------------------------
: B
V1 V2 V3
30 33 36

> as.data.frame(c(t)) ##return back to a
   A  B
V1 5 30
V2 7 33
V3 9 36





---------- Forwarded message ----------
> From: "Zhu, Lihua (Julie)" <Julie.Zhu@umassmed.edu>
> To: "Gordon K Smyth" <smyth@wehi.EDU.AU>, "Wendy Qiao" <
> wendy2.qiao@gmail.com>
> Date: Tue, 29 Mar 2011 10:28:14 -0400
> Subject: Re: [BioC] average replicate columns in a matrix
> Dear Gordon,
>
> Is there a corresponding method for sum over replicate arrays? Thank you so
> much for your help!
>
> Best regards,
>
> Julie
>
>
> On 3/28/11 6:08 PM, "Gordon K Smyth" <smyth@wehi.EDU.AU> wrote:
>
> > Dear Wendy,
> >
> > The function avearrays() in the limma package does exactly this:
> >
> >> library(limma)
> >> avearrays(test)
> >           A  B
> >    [1,] 2.5 10
> >    [2,] 3.5 11
> >    [3,] 4.5 12
> >
> > Best wishes
> > Gordon
>

	[[alternative HTML version deleted]]

