vperm | R Documentation |
This function first uses combn
to generate combinations of the desired size, then calculates all permutations of all said combinations.
vperm(x, m, FUN = NULL, ...)
x |
vector source for combinations, or integer n for x <- seq_len(n) |
m |
number of elements to choose in making the combinations |
FUN |
function to be applied to each combination; default NULL means the identity, i.e., to return the combination (vector of length m) |
... |
Additional arguments, if any, required for the function |
NA values are considered as valid elements and will be processed just as they are in combn
The input arguments are passed directly to combn
but with one important exception. combn
's argument "simplify" is forced to "TRUE" inside this function so as to allow the permutations to be more easily generated. If the user includes simplify = FALSE
in the ...
input, it will be overwritten.
An array within which each row contains one of the permutations.
Carl Witthoft, with some code taken from Sven Hohenstein via Stack Overflow
intersect
, the CRAN package sets
, perms
x <- c(1:5,3,3,3,2,NA,NA)
xp <- vperm(x,4) #large array
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.