I have a list of several (variable) letter numbers in combination, for example:
vec = c("a", "b", "c") comb = unlist(lapply(1:length(vec), combn, x = vec, simplify = FALSE), recursive = FALSE)
For each combination, I try to fill the elements, depending on the position, into vectors with the same length as the number of vectors. Therefore, I am trying to get:
a = 200 b = 020 c = 002 ab = 220 ac = 202 bc = 022 abc = 222
Now I am trying with loops replacing each element of the i, j array, but since all values are "2", should there be a more efficient way to do this? Thanks!!
arrays loops binary r combinations
user971102
source share