[R] Puzzled at generating combinations

Ajay Shah ajayshah at mayin.org
Tue Mar 18 16:05:05 CET 2008


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 at mayin.org                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.



More information about the R-help mailing list