# [BioC] average replicate columns in a matrix

Zhu, Lihua (Julie) Julie.Zhu at umassmed.edu
Tue Mar 29 16:28:14 CEST 2011

```Dear Gordon,

Is there a corresponding method for sum over replicate arrays? Thank you so

Best regards,

Julie

On 3/28/11 6:08 PM, "Gordon K Smyth" <smyth at 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
>
>> Date: Sun, 27 Mar 2011 19:25:29 -0400
>> From: Wendy Qiao <wendy2.qiao at gmail.com>
>> To: bioconductor at r-project.org
>> Subject: [BioC] average replicate columns in a matrix
>> Message-ID:
>> <AANLkTin7ZkTsaX4+T+X0zNMARYzzNG2kBtxxA-d-98db at mail.gmail.com>
>> Content-Type: text/plain
>>
>> I have a matrix like following
>>
>>> test=matrix(c(1:15),nrow=3,ncol=5)
>>> colnames(test)=c("A","A","B","B","B")
>>> test
>>     A A B  B  B
>> [1,] 1 4 7 10 13
>> [2,] 2 5 8 11 14
>> [3,] 3 6 9 12 15
>>
>> I want to calculate the average of each replicates, ie. I want the output to
>> be
>>     A B
>> [1,] 2.5 10
>> [2,] 3.5 11
>> [3,] 4.5 12
>>
>> I can do this by looping through each level of the column name, but I was
>> wondering if there is a function for calculating the average of replicates
>> in one step.
>>
>> Wendy
>
> ______________________________________________________________________
> The information in this email is confidential and intend...{{dropped:4}}
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

```