Skip to content

All combination

3 messages · Ron Michael, Dimitris Rizopoulos, David Winsemius

#
Please consider the following :
Var1 Var2 Var3
1     1    1    1
2     2    1    1
3     3    1    1
4     1    2    1
5     2    2    1
6     3    2    1
7     1    3    1
8     2    3    1
9     3    3    1
10    1    1    2
11    2    1    2
12    3    1    2
13    1    2    2
14    2    2    2
15    3    2    2
16    1    3    2
17    2    3    2
18    3    3    2
19    1    1    3
20    2    1    3
21    3    1    3
22    1    2    3
23    2    2    3
24    3    2    3
25    1    3    3
26    2    3    3
27    3    3    3


Now I want to remove the rows which has any repetition of number. For
example I want to remove row 1-5 but not 6 and so on........

Is there any easy way to do that?

Thanks,
#
have a look at function permutations from package 'e1071', e.g.,

library(e1071)
permutations(3)


I hope it helps.

Best,
Dimitris
RON70 wrote:

  
    
#
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 AM, RON70 wrote:

            
David Winsemius, MD
Heritage Laboratories
West Hartford, CT