On Thu, 2003-10-02 at 13:40, Paul Green wrote:
> Is there a function in R that will give all
> combination levels. For example, I see
> there is a "choose" function that gives
> 
>  >choose(5,2)
> 10
> 
> but I want
>       
>       1 2
>       1 3
>       1 4
>       1 5
>       2 3
>       2 4
>       2 5
>       3 4
>       3 5
>       4 5
> 
> This is a simple example. Actually I would like
> to do something like 10 choose 4.
> 
> Paul


See the combinations() function in the 'gregmisc' package on CRAN:

> combinations(5, 2)
      [,1] [,2]
 [1,]    1    2
 [2,]    1    3
 [3,]    1    4
 [4,]    1    5
 [5,]    2    3
 [6,]    2    4
 [7,]    2    5
 [8,]    3    4
 [9,]    3    5
[10,]    4    5

HTH,

Marc Schwartz

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to