Learn R Programming

RcppAlgos (version 2.9.3)

comboCount: Number of combinations/permutations

Description

Calculate 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, ...)

# S3 method for default comboCount(v, m = NULL, repetition = FALSE, freqs = NULL, ...) # S3 method for default permuteCount(v, m = NULL, repetition = FALSE, freqs = NULL, ...)

# S3 method for table comboCount(v, m = NULL, ...) # S3 method for table permuteCount(v, m = NULL, ...)

Value

A numerical value representing the total number of combinations/permutations.

Arguments

v

Source vector. If v is a positive integer, it will be converted to the sequence 1:v. If v is a negative integer, it will be converted to the sequence v:-1. All atomic types are supported (See is.atomic).

m

Number of elements to choose. If repetition = TRUE or freqs is utilized, m can exceed the length of v. If m = NULL, the length will default to length(v) or sum(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 of freqs represents how many times each element of the source vector, v, is repeated. It is analogous to the times argument in rep. The default value is NULL.

See Also

comboGeneral, permuteGeneral

Examples

Run this code
## Same interface as the respective "general" functions:
## i.e. comboGeneral & permuteGeneral

permuteCount(-5)
permuteCount(5)
comboCount(25, 12)
permuteCount(15, 7, TRUE)
comboCount(25, 12, freqs = rep(2, 25))

## Return object of class 'bigz'
comboCount(250, 15, freqs = rep(2, 250))

Run the code above in your browser using DataLab