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

Bert Gunter gunter.berton at gene.com
Mon May 27 18:30:12 CEST 2013

Homework? We don't do homework here.

-- Bert

On Mon, May 27, 2013 at 8:24 AM, Estigarribia, Bruno
<estigarr at email.unc.edu> wrote:
> 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.
> ______________________________________________
> 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.


Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374

More information about the R-help mailing list