[R] All combination

2009-11-13 Thread RON70
Please consider the following : expand.grid(rep(list(c(1:3)), 3)) Var1 Var2 Var3 1 111 2 211 3 311 4 121 5 221 6 321 7 131 8 231 9 331 10112 11212 1231

Re: [R] All combination

2009-11-13 Thread Dimitris Rizopoulos
have a look at function permutations from package 'e1071', e.g., library(e1071) permutations(3) I hope it helps. Best, Dimitris RON70 wrote: Please consider the following : expand.grid(rep(list(c(1:3)), 3)) Var1 Var2 Var3 1 111 2 211 3 311 4 1

Re: [R] All combination

2009-11-13 Thread David Winsemius
Besides the much more compact and probably more efficient approach of using permutation, here is another method: expand.grid(rep(list(c(1:3)), 3))[ lapply( apply( expand.grid(rep(list(c(1:3)), 3)), 1, unique), length) ==3 , ] On Nov 13, 2009, at 4:02