[R] Function for Generating all Permutations with Repetition
Martin Spindler
Martin.Spindler at gmx.de
Mon Mar 5 09:46:25 CET 2012
Dear all,
I am looking for a function in R which returns all possible permutations of an object x with r number of repitions. For example
If x <- c(0,1) and r <-3 the result should be
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
and consist of 2^3=8 elements.
Unfortunately, I have found only functions which return the combinations for "choose n over k" but not the case described above.
I would appreciate hints and help highly.
Best,
Martin
--
More information about the R-help
mailing list