tupleGen: Generate Tuples from Given Set

Description Usage Arguments Value Warning: Note

View source: R/tuples.R

Description

Determines if the vector or matrix supplied is unique along the first dimension. Useful for preparing for merges.

Usage

1
2
tupleGen(setn, k, as.num = FALSE, unique = FALSE, collapsed = FALSE)
permute(setn, as.num = FALSE)

Arguments

setn

a vector, the set of elements of which to find combinations or permutations

k

numeric, the size of the tuples

as.num

logical, defaults to FALSE. Determines whether to coerce to numeric. If setn is a purely numeric input, as.num will be forced to TRUE and can only be coerced to a character after the function call.

unique

logical, defaults to FALSE. Determines if elements may be duplicated in output

collapsed

ogical, defaults to FALSE. Determines whether or not to collapse each tuple to a string. Useful for random words or numbers.

Value

For tupleGen(), a matrix or vector of the specified combinations. For permute(), a matrix of vector of the permutations of the given set.

Warning:

These functions are currently implemented with a variety of loops, self-written code, and a top-down structure that creates and then searches all possibilities in order to subsets. Combinatorics generally grow rapidly with inputs, so be careful to manage memory. A faster implementation is most likely in the pipeline.

Note

permute() is merely a shorthand for calling:
tupleGen(setn, length(setn), as.num, unique = TRUE, collapsed = FALSE)


mattgarber4/myUtils documentation built on Dec. 13, 2020, 12:54 p.m.