[R] function for all binomial combinations?
chenxh007
chenxh007 at gmail.com
Thu Nov 22 19:23:53 CET 2007
t(combn(4,2)) in the package *combinat* produce this function.
Xiaohui
Michael Wolf wrote:
> Dear all,
>
> Is there a function that computes all binomial combinations.
> I am aware of the function "choose(n, k)" which computes the
> number of such combinations, but not the actual combinations
> themselves, e.g.:
>
> > choose(4, 2)
> [1] 6
>
> So I am looking for function that would give me the following
> matrix as output, say:
>
> > function(4, 2)
> [,1] [,2]
> [1,] 1 2
> [2,] 1 3
> [3,] 1 4
> [4,] 2 3
> [5,] 2 4
> [6,] 3 4
>
> Matlab has such function, but I could not find one in R.
>
> Please also reply directly to me: mwolf at iew.uzh.ch.
>
> Thanks much,
> Michael
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list