I hope to create all possible permutations of a vector containing two different values, in which I control the proportion of each of the values.
For example, if I have a vector of length three, and I want all possible combinations containing one 1, my desired output is a list that looks like this:
list.1 <- list(c(1,0,0), c(0,1,0), c(0,0,1))
In contrast, if I need all possible combinations containing three 1s, my desired result is a list that looks like this:
list.3 <- list(c(1,1,1))
In other words, the values of the template 1and 0has a value, but it 1should be considered as identical to the rest of 1s.
Based on the search here and elsewhere, I tried several approaches:
expand.grid(0:1, 0:1, 0:1)
permn(c(0,1,1))
unique(permn(c(0,1,1)))
, permn combinat . , ( 20, 50% 1 50% 0, :
unique(permn(c(rep(1,10), rep(0, 10))))
Error in vector("list", gamma(n + 1)) :
vector size specified is too large
, , permn , , , R.
- , ?
, - , SO, , , , .