I need to calculate for each element of my list all the combination of the elements inside and stock all the combination ( b in the example). I am currently doing like in my example but for a bigger list it is really slow because of the use of cbind in the loop. as i dont know the total final size of my vector b, i cant allocate an object at first. i am looking for other alternatives to make it more efficient.
b=0
a = list(id1=c(1,2,3,4,5,6),id2=c(10,11,12))
for(i in 1:length(a)){
temp=combn(a[[i]],2)
b=cbind(b,temp)
}