Hi guys.
I was wondering is it possible to create a matrix or a vector of permutations without repeating them.
E.g. create a matrix of 4! = 24 permutations.
The way I started is:
k <- 4
n <- factorial(k)
x <- matrix(NA,nrow= n, ncol =k)
for (i in 1:n){
x[i,] <- sample(k)
}
But i'm repeating some of the permutations.
Help is appreciated.
I was wondering is it possible to create a matrix or a vector of permutations without repeating them.
E.g. create a matrix of 4! = 24 permutations.
The way I started is:
k <- 4
n <- factorial(k)
x <- matrix(NA,nrow= n, ncol =k)
for (i in 1:n){
x[i,] <- sample(k)
}
But i'm repeating some of the permutations.
Help is appreciated.