Suppose we have generated a matrix A
where each column contains one of the combinations of n
elements in groups of k
. So, its dimensions will be k,choose(n,k)
. Such a matrix is produced giving the command combn(n,k)
. What I would like to get is another matrix B
with dimensions (n-k),choose(n,k)
, where each column B[,j]
will contain the excluded n-k
elements of A[,j]
.
Here is an example of the way I use tho get table B
. Do you think it is a safe method to use? Is there another way?
n <- 5 ; k <- 3
(A <- combn(n,k))
(B <- combn(n,n-k)[,choose(n,k):1])
Another example
x<-c(0,1,0,2,0,1) ; k<- 4
(A <- combn(x,k))
(B <- combn(x,length(x)-k)[,choose(length(x),k):1])
That previous question of mine is part of this problem.
Thank you.