Number of combinations/permutations
combinatoricsCount.RdCalculate the number of combinations/permutations of a vector chosen \(m\) at a time with or without replacement. Additionally, these functions can calculate the number of combinations/permutations of multisets.
Usage
comboCount(v, m = NULL, ...)
permuteCount(v, m = NULL, ...)
# Default S3 method
comboCount(v, m = NULL, repetition = FALSE, freqs = NULL, ...)
# Default S3 method
permuteCount(v, m = NULL, repetition = FALSE, freqs = NULL, ...)
# S3 method for class 'table'
comboCount(v, m = NULL, ...)
# S3 method for class 'table'
permuteCount(v, m = NULL, ...)Arguments
- v
Source vector. If
vis a positive integer, it will be converted to the sequence1:v. Ifvis a negative integer, it will be converted to the sequencev:-1. All atomic types are supported (Seeis.atomic).- m
Number of elements to choose. If
repetition = TRUEorfreqsis utilized,mcan exceed the length ofv. Ifm = NULL, the length will default tolength(v)orsum(freqs).- ...
Further arguments passed to methods.
- repetition
Logical value indicating whether combinations/permutations should be with or without repetition. The default is
FALSE.- freqs
A vector of frequencies used for producing all combinations/permutations of a multiset of
v. Each element offreqsrepresents how many times each element of the source vector,v, is repeated. It is analogous to thetimesargument inrep. The default value isNULL.
Examples
## Same interface as the respective "general" functions:
## i.e. comboGeneral & permuteGeneral
permuteCount(-5)
#> [1] 120
permuteCount(5)
#> [1] 120
comboCount(25, 12)
#> [1] 5200300
permuteCount(15, 7, TRUE)
#> [1] 170859375
comboCount(25, 12, freqs = rep(2, 25))
#> [1] 458917850
## Return object of class 'bigz'
comboCount(250, 15, freqs = rep(2, 250))
#> Big Integer ('bigz') :
#> [1] 1035444613157684247678300