Skip to content
Prev 311135 / 398506 Next

pairing data using combn with criteria

On Nov 17, 2012, at 10:07 AM, benjamin_jarrett wrote:

            
Please include context (and _do_ read the Posting Guide.) This is the suggestion I made before:
And this is how to apply it to the example:

 combn( row.names(data), 2, FUN = function(b){ 
                 if (data[b[1], "fam" ] != data[b[2], "fam"] ) { b } else { c(NA,NA) } } )

     [,1] [,2] [,3] [,4] [,5] [,6]
[1,] "1"  NA   "1"  "2"  NA   "3" 
[2,] "2"  NA   "4"  "3"  NA   "4"