Re: [R] how to do pairwise sums in a matrix

2008-05-21 Thread Henrique Dallazuanna
Try this: t(rowsum(t(Mat), substr(colnames(Mat), 1, 1))) On Wed, May 21, 2008 at 2:22 PM, Gregory Gentlemen < [EMAIL PROTECTED]> wrote: > I am looking for an efficient way to solve the following problem. I have a > large matrix of continuous values with a small proportion of missing values. > Co

Re: [R] how to do pairwise sums in a matrix

2008-05-21 Thread Jorge Ivan Velez
Hi Gregory, Try this: cs=substr(colnames(Mat),1,1) res=t(apply(t(Mat),2,tapply,cs,sum,na.rm=TRUE)) dim(res) [1] 50 5 HTH, Jorge On Wed, May 21, 2008 at 1:22 PM, Gregory Gentlemen < [EMAIL PROTECTED]> wrote: > I am looking for an efficient way to solve the following problem. I have a > large

[R] how to do pairwise sums in a matrix

2008-05-21 Thread Gregory Gentlemen
I am looking for an efficient way to solve the following problem. I have a large matrix of continuous values with a small proportion of missing values. Columns correspond to variables where each variable has two measurements, call them A and B. The matrix is such that the columns are in sequence