[R] Puzzled at generating combinations

From: Ajay Shah <ajayshah_at_mayin.org>
Date: Tue, 18 Mar 2008 20:35:05 +0530


I have two data frames. Suppose the first has rows

r1
r2
r3

and the second has rows

R1
R2
R3

I'd like to generate the data frame:

    r1 R1
    r1 R2
    r1 R3

    r2 R1
    r2 R2
    r2 R3
    r3 R1
    r3 R2
    r3 R3

How would I go about doing this? I'm sure there's a clean way to do it but I find myself thinking in loops.

-- 
Ajay Shah                                      http://www.mayin.org/ajayshah  
ajayshah@mayin.org                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.

______________________________________________
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.
Received on Tue 18 Mar 2008 - 15:09:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Mar 2008 - 17:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive