permute_combinations_with_replacement: Permute all combinations of x of size m with replacement

View source: R/permute_combinations_with_replacement.r

permute_combinations_with_replacementR Documentation

Permute all combinations of x of size m with replacement

Description

Given a vector x, permutes all possible groups of size m ignoring order and allowing any item in x to appear multiple times.

Usage

permute_combinations_with_replacement(x, m)

Arguments

x

A character vector.

m

A positive integer indicating the size of the set desired.

Details

This is a simple combinatoric function used internally in Claddis where all possible combinations of x that are size m are permuted. Note that this ignores order (i.e., the sets \A,B\ and \B,A\ are considered identical) and replacements (or multiples) of an element of x are allowed (i.e., the sets \A,A\ and \B,B\ are both valid).

Value

A matrix of m columns where each row is a unique combination of x.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples


# Permute all the ways the letters A-C can form a set of size 3:
permute_combinations_with_replacement(x = LETTERS[1:3], m = 3)


graemetlloyd/Claddis documentation built on June 12, 2025, 10:45 p.m.