Learn R Programming

RcppAlgos (version 2.9.3)

expandGridCount: Count of the Cartesian Product

Description

Calculate the number of Cartesian products of the input vectors.

Usage

expandGridCount(...)

Value

When the number of results exceeds \(2^{53} - 1\), a number of class bigz is returned.

Arguments

...

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

Author

Joseph Wood

See Also

expandGrid

Examples

Run this code
## description example
lst = list(1:2, 1:2)

## Using base R
t = expand.grid(lst)
nrow(t)

## vs calling expandGridCount directly
expandGridCount(lst)

## Call it just like you would if you were generating the results
expandGridCount(1:5, 3:9, letters[1:5], letters[c(1,4,5,8)])

## Same as
nrow(expand.grid(1:5, 3:9, letters[1:5], letters[c(1,4,5,8)]))

lst = Map(function(x, y) x:y, 8:33, 15:40)

## Return object of class 'bigz'
expandGridCount(lst)

Run the code above in your browser using DataLab