Learn R Programming

forensim (version 1.1-4)

comb: Generate all possible combinations of m elements among n with repetitions

Description

Generate all possible combinations of m elements among n with repetitions.

Usage

comb(m, n)

Arguments

m
the number of elements to combine
n
the number of elements from which to combine the m elements

Value

  • A matrix of (n+m-1)!/(m!(n-1)!) rows, and n columns, each row is a possible combination of m elements among n .

encoding

UTF-8

Details

There are (n+m-1)!/(m!(n-1)!) ways to combine m elements among n with repetitions, combn generates all these possible combinations.

See Also

Cmn for the calculation of the number of all possible combinations of m elements among n with repetitions

Examples

Run this code
#combine 2 objects among 3 with repetitions
Cmn(2,3)
comb(2,3)

Run the code above in your browser using DataLab