View source: R/general_utils.R
permutationz | R Documentation |
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.
permutationz(n, r, v = 1:n, set = TRUE, repeats.allowed = FALSE)
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. |
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.
Returns a matrix where each row contains a vector of length r.
See the authors in gtools::permutations()
# permutationz(n = length(c('A', 'T', 'C', 'G')), r = 6, v = c('A', 'T', 'C', 'G'), repeats.allowed = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.