[R] Using indexing to manipulate data

duncandonutz dwadswor at unm.edu
Thu Mar 18 06:05:38 CET 2010

I know one of R's advantages is it's ability to index, eliminating the need
for control loops to select relevant data, so I thought this problem would
be easy.  I can't crack it.  I have looked through past postings, but
nothing seems to match this problem

I have a data set with one column of actors and one column of acts.  I need
a list that will give me a pair of actors in each row, provided they both
participated in the act.


The Data looks like this:
Jim         A
Bob        A
Bob        C 
Larry      D
Alice      C
Tom       F
Tom       D
Tom       A  
Alice      B
Nancy    B

I would like this:
Jim      Bob
Jim      Tom
Bob     Alice
Larry   Tom
Alice    Nancy

The order doesn't matter (Jim-Bob vs. Bob-Jim), but each pairing should be
counted only once.

View this message in context: http://n4.nabble.com/Using-indexing-to-manipulate-data-tp1597547p1597547.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list