Re: [R] Function for Generating all Permutations with Repetition

2012-03-05 Thread Dimitris Rizopoulos
Have a look at expand.grid(), e.g., expand.grid(rep(list(0:1), 3)) I hope it helps. Best, Dimitris On 3/5/2012 9:46 AM, Martin Spindler wrote: 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<-

[R] Function for Generating all Permutations with Repetition

2012-03-05 Thread Martin Spindler
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 on