Calculate average of replicates
1
0
Entering edit mode
Wendy Qiao ▴ 10
@wendy-qiao-4565
Last seen 9.6 years ago
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. Thank you in advance. Wendy [[alternative HTML version deleted]]
• 730 views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 2 hours ago
United States
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
ADD COMMENT

Login before adding your answer.

Traffic: 582 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6