[BioC] Calculate average of replicates

James W. MacDonald jmacdon at med.umich.edu
Mon Mar 28 21:20:37 CEST 2011


Hi Wendy,

On 3/27/2011 6:47 PM, Wendy Qiao wrote:
> Hi all,
>
>
>
> 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.

This question has nothing to do with Bioconductor, so you should be 
asking on R-help.

However, ?aggregate.

Best,

Jim


>
>
>
> Thank you in advance.
>
> Wendy
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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

-- 
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues 



More information about the Bioconductor mailing list