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 <[EMAIL PROTECTED]> To: r-help <[EMAIL PROTECTED]> 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 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help