Ordered Permutation


Ambassador to the humans
The combinat package can do this for you fairly easily
# you can use whatever you want though...
permn(c("a", "b", "c"))
@Dason. thanks a lot, but this does not work for large size i.e. permn(1:36), further, can i store these permutation into a matrix and use one by one through for loop in a check process?


Probably A Mammal
Since it returns a list of equal length vectors, you can use do.call to row bind them all together

do.call("rbind", permn(1:3))
What do.call does is execute "rbind" with the elements of permn(1:3), in this case, as the arguments. In other words, if permn(1:3) were stored in 'x', then it's equivalent to running

rbind(x[[1]], x[[2]], x[[3]], x[[4]], x[[5]], x[[6]])
Not very nice to do, especially if you had to bind 36 elements! So when you get list objects you need to reshape into something a bit nicer, always think do.call. It can often prove useful.
@bryangoodrich, thanks dear. do call really works here to generate a matrix but the matter of large permutation is still unsolved. I further want to generate (nPr) permutations, i.e 37P10 etc.