expand.grid.DT: Expand.grid using the data.table package.

Description Usage Arguments Value Examples

View source: R/finitepop.R

Description

Expand.grid (expand.grid) using the data.table package, with up to 4 supplied vectors.

Usage

1
expand.grid.DT(seq1, seq2, seq3 = NA, seq4 = NA, col.names = NA)

Arguments

seq1

Vector of values.

seq2

Vector of values.

seq3

Vector of values.

seq4

Vector of values.

col.names

Names of columns.

Value

A data.table with all possible combinations (Cartesian product) of the elements in the input vector sequences.

Examples

1
2
3
expand.grid.DT(1:10, 100:110)
expand.grid.DT(1:10, 100:110, col.names=c("A", "B"))
expand.grid.DT(1:10, 100:110, 11:13, 1:2)

Example output

     seq1 seq2
  1:    1  100
  2:    1  101
  3:    1  102
  4:    1  103
  5:    1  104
 ---          
106:   10  106
107:   10  107
108:   10  108
109:   10  109
110:   10  110
      A   B
  1:  1 100
  2:  1 101
  3:  1 102
  4:  1 103
  5:  1 104
 ---       
106: 10 106
107: 10 107
108: 10 108
109: 10 109
110: 10 110
     seq1 seq2 seq3 seq4
  1:    1  100   11    1
  2:    1  100   11    2
  3:    1  100   12    1
  4:    1  100   12    2
  5:    1  100   13    1
 ---                    
656:   10  110   11    2
657:   10  110   12    1
658:   10  110   12    2
659:   10  110   13    1
660:   10  110   13    2

noncompliance documentation built on May 2, 2019, 2:38 a.m.