x <- expand.grid(seq(0.1,1,0.05),
seq(0.1,1,0.05),
seq(0.1,1,0.05))
x <- x [rowSums (x) == 1,]
Edit: Use this instead to avoid floating point errors:
x <- x[abs(rowSums(x)-1) < .Machine$double.eps ^ 0.5,]
unique(apply(x,1,sort), MARGIN=2)
This will lead to performance and memory problems if the possible number of combinations is huge.
source
share