Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ncombinations

Number of combinations


Description

Number of combinations

Usage

ncombinations(x = NULL, k = NULL, n = NULL, v = NULL,
  freq = NULL, replace = FALSE, bigz = FALSE)

Arguments

x

an integer or a vector, will be treated as n if integer; otherwise, will be treated as v. Should not be specified together with n and v.

k

an integer, the number of items drawn, defaults to n if freq is NULL else sum(freq)

n

an integer, the total number of items, its value may be implicitly deduced from length(v) or length(freq)

v

a vector to be drawn, defaults to 1:n.

freq

an integer vector of item repeat frequencies

replace

an logical to draw items with replacement

bigz

an logical to use gmp::bigz

See Also

combinations for generating all combinations and icombinations for iterating combinations

Examples

ncombinations(5, 2)
ncombinations(LETTERS, k = 5)

# integer overflow
## Not run: ncombinations(40, 15)
ncombinations(40, 15, bigz = TRUE)

# number of combinations of `c("a", "b", "b")`
# they are `c("a", "b")` and `c("b", "b")`
ncombinations(k = 2, freq = c(1, 2))

# zero sized combinations
ncombinations(5, 0)
ncombinations(5, 6)
ncombinations(0, 1)
ncombinations(0, 0)

arrangements

Fast Generators and Iterators for Permutations, Combinations, Integer Partitions and Compositions

v1.1.9
MIT + file LICENSE
Authors
Randy Lai [aut, cre]
Initial release
2020-09-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.