comboGrid {RcppAlgos}R Documentation

Efficient Version of expand.grid Where order Does Not Matter

Description

This function efficiently generates Cartesian-product-like output where order does not matter. It is loosely equivalent to the following:

Usage

comboGrid(..., repetition = TRUE)

Arguments

...

vectors, factors or a list containing these. (See ?expand.grid).

repetition

Logical value indicating whether results should be with or without repetition. The default is TRUE.

Value

If items with different classes are passed, a data frame will be returned, otherwise a matrix will be returned.

Author(s)

Joseph Wood

Examples

## return a matrix
expGridNoOrder = comboGrid(1:5, 3:9, letters[1:5], letters[c(1,4,5,8)])
head(expGridNoOrder)
tail(expGridNoOrder)

expGridNoOrderNoRep = comboGrid(1:5, 3:9, letters[1:5],
                                letters[c(1,4,5,8)], repetition = FALSE)

head(expGridNoOrderNoRep)
tail(expGridNoOrderNoRep)

[Package RcppAlgos version 2.8.3 Index]