[R] row-wise means

Peter Alspach Peter.Alspach at plantandfood.co.nz
Thu Nov 19 00:01:22 CET 2009


Tena koe Anjan

?rowMeans
?apply

You'll need to subset your data matrix to exclude the first column
(e.g., yourData[,-1]).

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of ANJAN PURKAYASTHA
> Sent: Thursday, 19 November 2009 11:28 a.m.
> To: r-help at r-project.org
> Subject: [R] row-wise means
> 
> I have a dataframe with 3 columns. The first column stores an 
> index. I would like to calculate the mean of the numbers 
> stored in each of the rest of the columns.
> So,
> here is my data matrix:
> col1 col2 col3
> 1 23 34
> 2 45 56
> 3 23 56
> 4 34 68
> 
> For each row I would like to calculate the means of the 
> numbers stored in
> col2 and col3.
> How can this be done in R?
> TIA,
> Anjan
> 
> --
> =============================
> anjan purkayastha, phd
> bioinformatics analyst
> whitehead institute for biomedical research nine cambridge 
> center cambridge, ma 02142
> 
> purkayas [at] wi [dot] mit [dot] edu
> 703.740.6939
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 




More information about the R-help mailing list