Re: [R] Collapsing/aggregating columns in a matrix

2011-03-24 Thread Ista Zahn
Hi Barth, Use rowMeans() like this: mat <- matrix(rnorm(100), ncol=10) cbind(sum1.5 = rowSums(mat[,1:5]), sum2.6 = rowSums(mat[,2:6])) Best, Ista On Thu, Mar 24, 2011 at 12:10 PM, Barth B. Riley wrote: > Dear list > > I want to know if there is a function in R that enables one to create a new >

[R] Collapsing/aggregating columns in a matrix

2011-03-24 Thread Barth B. Riley
Dear list I want to know if there is a function in R that enables one to create a new matrix based on values in an existing matrix, whereby each column in the new matrix is a row-specific summary (e.g., sum, mean) of multiple columns in the original matrix. For instance, to take a 12-column mat