vperm: Calculate all permutations of all combinations of a specified size from a data object.
Description
This function first uses combn to generate combinations of the desired size, then calculates all permutations of all said combinations.
Usage
vperm(x, m, FUN = NULL, ...)
Value
An array within which each row contains one of the permutations.
Arguments
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 FUN . See Details.
Author
Carl Witthoft, with some code taken from Sven Hohenstein via Stack Overflow
Details
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.