fastcombn | R Documentation |
Generate all combinations of the elements of x taken m at a time. If x is a positive integer, returns all combinations of the elements of seq(x) taken m at a time.
fastcombn(x, m, FUN = NULL, simplify = TRUE, ...)
combn_prim(x, m, simplify = TRUE)
x |
vector source for combinations, or integer n for x <- seq(n). |
m |
number of elements to choose. |
FUN |
function to be applied to each combination; default ‘NULL’ means the identity, i.e., to return the combination (vector of length ‘m’). |
simplify |
logical indicating if the result should be simplified to a matrix; if FALSE, the function returns a list. |
... |
Further arguments passed on to |
Factors x
are accepted.
combn_prim
is a simplified (but faster) version of the combn
function. Does nok take the FUN
argument.
fastcombn
is intended to be a faster version of the combn
function.
A matrix or a list.
Søren Højsgaard
combn
x <- letters[1:5]; m <- 3
fastcombn(x, m)
combn(x, m)
combn_prim(x, m)
x <- letters[1:4]; m <- 3
fastcombn(x, m, simplify=FALSE)
combn(x, m, simplify=FALSE)
combn_prim(x, m, simplify=FALSE)
x <- 1:10; m <- 3
fastcombn(x, m, min)
combn(x, m, min)
x <- factor(letters[1:8]); m <- 5
if (require(microbenchmark)){
microbenchmark(
combn(x, m, simplify=FALSE),
combn_prim(x, m, simplify=FALSE),
fastcombn(x, m, simplify=FALSE),
times=50
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.