Generates all combinations of length m of a vector a.

combs(a, m)

Arguments

a

numeric vector of some length n

m

integer with 0 <= m <= n

Details

combs generates combinations of length n of the elements of the vector a.

Value

matrix representing combinations of the elements of a

See also

Examples

combs(seq(2, 10, by=2), m = 3)
#>       [,1] [,2] [,3]
#>  [1,]    2    4    6
#>  [2,]    2    4    8
#>  [3,]    2    4   10
#>  [4,]    2    6    8
#>  [5,]    2    6   10
#>  [6,]    2    8   10
#>  [7,]    4    6    8
#>  [8,]    4    6   10
#>  [9,]    4    8   10
#> [10,]    6    8   10