I have 4 lists
a <- list(1,2,3,4) b <- list(5,6,7,8) c <- list(7,9,0) d <- list(12,14)
I would like to know which of the lists have elements in common. In this example, lists
c have the element 7 in common.
A brute force approach would be to take every combination of lists and find the intersection. Is there any other efficient way to do it in R?
Another approach would be to make a single list from all the lists and find the duplicates. Then maybe we could have a mapping function to indicate from which original lists these duplicates are from. But am not so sure about how to do it. I came across this post
I was thinking if we could modify this to find out the actual lists which have duplicates.
I have to repeat this process for many groups of lists. Any suggestions/ideas are greatly appreciated! Thanks in advance