expand.grid.jc: An even faster version of expand.grid

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/BioGeoBEARS_basics_v1.R

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

1
  expand.grid.jc(seq1, seq2)

Arguments

seq1

A sequence of elements

seq2

A sequence of elements

Details

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

Value

matrix_of_combinations A matrix of all the possible combinations.

Note

Go BEARS!

Author(s)

Nicholas J. Matzke [email protected]

References

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

Matzke_2012_IBS

See Also

convolve, expand.grid, expand.grid.jc

Examples

1
2
3
4
5
6
testval=1
seq1 = c("A","B","C")
seq2 = seq1
expand.grid(seq1,seq2)
expand.grid.alt(seq1,seq2)
expand.grid.jc(seq1,seq2)

Example output

Loading required package: rexpokit
Loading required package: cladoRcpp
Loading required package: ape
Loading required package: phylobase

Attaching package: 'phylobase'

The following object is masked from 'package:ape':

    edges

  Var1 Var2
1    A    A
2    B    A
3    C    A
4    A    B
5    B    B
6    C    B
7    A    C
8    B    C
9    C    C
      [,1] [,2]
 [1,] "A"  "A" 
 [2,] "B"  "A" 
 [3,] "C"  "A" 
 [4,] "A"  "B" 
 [5,] "B"  "B" 
 [6,] "C"  "B" 
 [7,] "A"  "C" 
 [8,] "B"  "C" 
 [9,] "C"  "C" 
      Var1 Var2
 [1,] "A"  "A" 
 [2,] "B"  "A" 
 [3,] "C"  "A" 
 [4,] "A"  "B" 
 [5,] "B"  "B" 
 [6,] "C"  "B" 
 [7,] "A"  "C" 
 [8,] "B"  "C" 
 [9,] "C"  "C" 

BioGeoBEARS documentation built on May 29, 2017, 8:36 p.m.