Hello,
I have two sets of lists, with three lists in each set. Now my goal is to find the union (both common and uncommon) of the two sets of lists.
l1 <- list(c(1, 2, 5), c(1,5), c(1, 2, 5))
l2 <- list(c(1, 4, 5, 16, 31, 40, 50), c(1, 4, 5, 39), c(1, 2, 5, 28, 34, 40, 45, 49))
The output should look like
[[1]] 1 2 5
[[2]] 1 3 5
[[3]] 1 2 5 28
l <- list(l1, l2)
uni = list(union(l[[1]][[1]], l[[2]][[1]]))
uni = list(union(l[[1]][[2]], l[[2]][[2]]))
uni = list(union(l[[1]][[3]], l[[2]][[3]]))
Eventually, I will have 100 lists in each set. I can do the task one by one, but it's not an efficient way to do it 100 times for 100 lists. Can anyone help me to do it efficiently, possibly using for loop? Thanks!