generate_combinations_with_replacement: Helper function to generate combinations with replacement

View source: R/generation_powers.R

generate_combinations_with_replacementR Documentation

Helper function to generate combinations with replacement

Description

This very simple helper generates combinations with replacement.

Usage

generate_combinations_with_replacement(x, k)

Arguments

x

vector of elements to choose from.

k

number of elements to choose.

Details

This is replicating the functionality from arrangements::combinations with replace = TRUE. Note that base R function utils::combn only returns combinations without replacement, thus pairs like (0, 0) are not in the output.

Note that this function is extremely inefficient and only intended to be used with small use cases, i.e. small k. This is typically the case in the context of MFP, but a warning is given if this is not the case since the algorithm may take a while to compute the combinations, and even longer to do model selection.

Value

A m x k matrix, where m is the number of combinations.


mfp2 documentation built on Nov. 15, 2023, 1:06 a.m.