[R] How Can I Concatenate Every Row in a Data Frame with Every Other Row?

Donald Macnaughton donmac at matstat.com
Sat Mar 21 17:01:40 CET 2009


I have a data frame with roughly 500 rows and 120 variables.  I would like
to generate a new data frame that will include one row for each PAIR of
rows in the original data frame and will include all 120 + 120 = 240
variables from the two rows.  I need only one row for each pair, not two
rows.  Thus the new data frame will contain 500 x 499 / 2 = 124,750 rows.  
 
Is there an easy way to do this with R?  
 
Thanks in advance,
 
Don Macnaughton




More information about the R-help mailing list