Skip to content
Prev 139623 / 398506 Next

mean for each row

You need to omit the last column, though:

RowM <- rowMeans(x[, -ncol(x)])

for example.



-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Matthias Kohl
Sent: Monday, 17 March 2008 4:14 PM
To: Hesen Peng
Cc: R help forum
Subject: Re: [R] mean for each row

or rowMeans ...
Matthias
Hesen Peng wrote:
wrote:
help.
Totals
38.4
25.6
26.8
49.4
34.6
17.8
6.0
10.0
0.0
3.8
17.0
16.8
34.0
2.8
3.6
23.2
2.8
19.2
0.4
8.2
0.0
0.4
1.2
11.2
16.2
41.0
13.8
9.8
12.6
4.8
6.2
457.6
________________________________________________________________________
____________
http://www.R-project.org/posting-guide.html