[R] Finding common sets

Gabor Grothendieck ggrothendieck at myway.com
Thu Oct 30 21:43:17 CET 2003


If A is the incidence matrix whose columns represent groups 
and whose rows represent elements then the i,j-th element of 
the cross product matrix, crossprod(A), is the number of 
common elements in group i and group j.

In your case A has the form cbind(A1,A2) and you only need 
the block cross diagonal elements, namely crossprod(A1,A2).


---
From: Sean Davis <sdavis2 at mail.nih.gov>
To: r-help <r-help at stat.math.ethz.ch> 
Subject: [R] Finding common sets 

 
 
I am working on a problem in which I have 2 groups of clusters, each of
which was generated from the same original list of members. Within each
group, the clusters cover the original list of members many times over.
What I am interested in finding is the number of common elements in every
pair of clusters when taking one from each group. In short, I need a FAST
way of finding the number of common elements in two groups, as this process
will be over all pairs. (The elements in the two groups can be numeric if
absolutely necessary, but it would be nice to be general here.)

Thanks,
Sean

-- 
Clinical Fellow
National Institutes of Health
NCI/NHGRI


_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com




More information about the R-help mailing list