I am working in R. I have two vectors; A and B of lengths 5913 and 3733 respectively (with entries are repeated). I want to extract those values (with repetitions) that are present in both A and B. I have done (A %in% B) (lets call it C) and (B %in% A) (lets call it D). The length of C is 3906 and that of D is 3607 (so 2007 elements in A are not in B and 126 elements in B are not in A).
But How do I find the common values ? I don't think I can use intersect() method as it expects vectors with no duplicate values. I have many many repetitions.
Note: Due to the length of these vectors, I couldn't mention them here.
Any help would be greatly appreciated.
Thanks
A = c(1,1,2,2,3,3,4,4,5,5,6,6,9,11,15,17,19,19)
andB = c(1,2,2,2,3,3,3,4,5,6,7,8,8,8)
what will your result look like? One possibility isC=[1 1 2 2 3 3 4 4 5 5 6 6]
. Another isD=[1 2 2 2 3 3 3 4 5 6]
. Do you needE = [1 1 2 2 2 3 3 4 4 5 5 6 6]
? $\endgroup$