Number of combinations
ncombinations(x = NULL, k = NULL, n = NULL, v = NULL, freq = NULL, replace = FALSE, bigz = FALSE)
x | an integer or a vector, will be treated as |
---|---|
k | an integer, the number of items drawn, defaults to |
n | an integer, the total number of items, its value may be implicitly deduced from |
v | a vector to be drawn, defaults to |
freq | an integer vector of item repeat frequencies |
replace | an logical to draw items with replacement |
bigz | an logical to use gmp::bigz |
combinations for generating all combinations and icombinations for iterating combinations
ncombinations(5, 2)#> [1] 10ncombinations(LETTERS, k = 5)#> [1] 65780# integer overflow if (FALSE) ncombinations(40, 15) ncombinations(40, 15, bigz = TRUE)#> Big Integer ('bigz') : #> [1] 40225345056# number of combinations of `c("a", "b", "b")` # they are `c("a", "b")` and `c("b", "b")` ncombinations(k = 2, freq = c(1, 2))#> [1] 2# zero sized combinations ncombinations(5, 0)#> [1] 1ncombinations(5, 6)#> [1] 0ncombinations(0, 1)#> [1] 0ncombinations(0, 0)#> [1] 1