值I具有的字母数(可变)数量的组合的列表,例如这样的:ř填补取决于组合
vec = c("a", "b", "c")
comb = unlist(lapply(1:length(vec), combn, x = vec, simplify = FALSE), recursive = FALSE)
# this creates all the combinations of the vector I am interested in, i.e. for three letters:
# a b c ab ac bc abc
对于每个组合,我试图填补根据位置元素,成与矢量数量相同长度的矢量。所以,我想获得:
a = 200
b = 020
c = 002
ab = 220
ac = 202
bc = 022
abc = 222
现在我用循环替换阵列I,J,但由于所有值的每个元素都试图“2”,必须有这样做更有效的方式? 非常感谢!
'comb_cases'非常聪明 –