[R] All combination
David Winsemius
dwinsemius at comcast.net
Sat Nov 14 05:40:09 CET 2009
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:
>
> Please consider the following :
>
>> expand.grid(rep(list(c(1:3)), 3))
> 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,
> --
> View this message in context: http://old.nabble.com/All-combination-tp26333348p26333348.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list