[R] average of rows of each column

David Carlson dcarlson at tamu.edu
Fri Apr 4 22:14:32 CEST 2014

Something like (only 20 columns here):

x <- matrix(rnorm(120*20), 120, 20)
xagg <- aggregate(x, list(rep(1:12, each=10)), mean)

David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of eliza botto
Sent: Friday, April 4, 2014 1:08 PM
To: r-help at r-project.org
Subject: [R] average of rows of each column

Dear useRs,
I have a matrix of 120 row and 1000 columns.What I want is to
get an average of a set of 12 rows starting from 1 till 120 for
each column. Precisely, for column 1 the average of 1:10 rows,
11:20 rows.... 111:120. similarly for column 2, 3, 4.... 1000.
So in the end i should have a matrix with 12 rows and 1000
Thankyou very much in advance.

	[[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible

More information about the R-help mailing list