permutationz: My local function to enumerate the Permutations of the...

View source: R/general_utils.R

permutationzR Documentation

My local function to enumerate the Permutations of the Elements of a Vector

Description

This is a copy of the gtools::permutations() function. So I have one less dependency to handle since I only need this great function from that package.

Usage

permutationz(n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE)

Arguments

n

Size of the source vector

r

Size of the target vectors

v

Source vector. Defaults to 1:n

set

Logical flag indicating whether duplicates should be removed from the source vector v. Defaults to TRUE.

repeats.allowed

Logical flag indicating whether the constructed vectors may include duplicated values. Defaults to FALSE.

Details

Caution: The number of combinations and permutations increases rapidly with n and r!. To use values of n above about 45, you will need to increase R's recursion limit. See the expression argument to the options command for details on how to do this. Taken from an email by Brian D Ripley to r-help dated Tue, 14 Dec 1999 11:14:04 +0000 (GMT) in response to Alex Ahgarin. Original version was named "subsets" and was Written by Bill Venables.

Value

Returns a matrix where each row contains a vector of length r.

Author(s)

See the authors in gtools::permutations()

Examples

# permutationz(n = length(c('A', 'T', 'C', 'G')), r = 6, v = c('A', 'T', 'C', 'G'), repeats.allowed = TRUE)

Ni-Ar/niar documentation built on Feb. 3, 2025, 9:25 a.m.