Learn R Programming

BioGeoBEARS (version 0.2.1)

expand.grid.alt: A faster version of expand.grid

Description

This should be faster than expand.grid, which "[c]reate[s] a data frame from all combinations of the supplied vectors or factors" (R documentation).

Usage

expand.grid.alt(seq1, seq2)

Arguments

seq1
A sequence of elements
seq2
A sequence of elements

Value

matrix_of_combinations A matrix of all the possible combinations.

Details

The source of this function was this discussion thread: http://stackoverflow.com/questions/10405637/use-outer-instead-of-expand-grid

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

convolve, expand.grid, expand.grid.jc

Examples

Run this code
testval=1
seq1 = c("A","B","C")
seq2 = seq1
expand.grid(seq1,seq2)
expand.grid.alt(seq1,seq2)
expand.grid.jc(seq1,seq2)

Run the code above in your browser using DataLab