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

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon May 27 18:40:31 CEST 2013


I expect the answer to involve manipulating indices. But why do you need to do this? This looks suspiciously like homework, and there is a no-homework policy on this list (see the Posting Guide).
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

"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.



More information about the R-help mailing list