[R] How sum all possible combinations of rows, given 4 matrices

Estigarribia, Bruno estigarr at email.unc.edu
Mon May 27 17:24:51 CEST 2013


Hello all,

I have 4 matrices with 3 columns each (different number of rows though). I
want to find a function that returns all possible 3-place vectors
corresponding to the sum by columns of picking one row from matrix 1, one
from matrix 2, one from matrix 3, and one from matrix 4. So basically, all
possible ways of picking one row from each matrix and then sum their
columns to obtain a 3-place vector.
Is there a way to use expand.grid and reduce to obtain this result? Or am
I on the wrong track?
Thank you,
Bruno
PS:I believe I have given all relevant info. I apologize in advance if my
question is ill-posed or ambiguous.



More information about the R-help mailing list