Generates a list with two arrays of indices that make up complete enumeration of all combinations (order does not matter) of elements of vector of length n.

combination_indices(n, repeats = FALSE)

Arguments

n

Number of elements in vector to get combinations of

repeats

Do we allow repeats in pairs? E.g. should a-a, b-b, etc. be allowed in generated pairs?

Value

A list with two vectors ($a and $b) containing integer indices of elements for every pair.

See also

Examples

if (FALSE) { my_letters <- head(letters, 5) letter_pairs <- combination_indices(length(my_letters), repeats = FALSE) dplyr::tibble( letter_1 = letters[letter_pairs$a], letter_2 = letters[letter_pairs$b] ) }