I have a list containing several vectors, e.g.:
ls=list(c("g1","g3","g6"),c("g1","g4"),c("g2","g5"),c("g2","g5"),c("g2"))
I want to capture the minimum number of elements so that I have at least one element from each vector.
So in this example, "g1" and "g2" because g1 captures vectors 1 and 2 and g2 captures vectors 1, 3, 4 and 5.
I've been looking at How to find common elements from multiple vectors? but it isn't quite the same question.