[R] average of rows of each column

dcarlson at tamu.edu dcarlson at tamu.edu
Mon Apr 7 18:10:16 CEST 2014


Actually how about 1:30pm today. I'm on Alvard's Jobinar panel
from 12:30-1:30pm.

David

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of David Carlson
Sent: Friday, April 4, 2014 3:15 PM
To: 'eliza botto'; r-help at r-project.org
Subject: Re: [R] average of rows of each column

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
columns.
Thankyou very much in advance.

Eliza
 		 	   		  
	[[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.

______________________________________________
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