Last chance! 50% off unlimited learning
Sale ends in
CombN
computes the number of combinations with and without replacement and order, whereas CombSet
returns the value sets.Permn(x, sort = FALSE)
CombN(x, m, repl = FALSE, ord = FALSE)
CombSet(x, m, repl = FALSE, ord = FALSE, as.list = FALSE)
CombSet
can m
be a numeric vector too.Permn
and CombSet
if m contains more than one element the result will be a list of matrices or a flat list if as.list
is set to TRUE
an integer value for CombN
combn
, choose
, factorial
, CombPairs
vignette("Combinatorics")
Permn(letters[2:5])
Permn(2:5)
# containing the same element more than once
Permn(c("a", "b", "c", "a"))
# only combinations of 2, but in every possible order
x <- letters[1:4]
m <- 2
# the samples
CombSet(x, m, repl=TRUE, ord=FALSE)
CombSet(x, m, repl=TRUE, ord=TRUE)
CombSet(x, m, repl=FALSE, ord=TRUE)
CombSet(x, m, repl=FALSE, ord=FALSE)
# the number of the samples
CombN(x, m, repl=TRUE, ord=FALSE)
CombN(x, m, repl=TRUE, ord=TRUE)
CombN(x, m, repl=FALSE, ord=TRUE)
CombN(x, m, repl=FALSE, ord=FALSE)
# build all subsets of length 1, 3 and 5 and return a flat list
x <- letters[1:5]
CombSet(x=x, m=c(1, 3, 5), as.list=TRUE)
Run the code above in your browser using DataLab