Create the Cartesian product of two or more data sets, preserving all variables from each input data set.

genCrossed(..., id = "cross_id")

Arguments

...

Two or more data sets to be crossed. Each input may be a `data.frame` or `data.table`.

id

Name of the crossed id field. Defaults to `"cross_id"`.

Value

A `data.table` containing all combinations of rows from the input data sets. The crossed id is placed first and used as the key.

Examples

region_def <- defData(varname = "r_effect", formula = 0, variance = 1)
mouse_def <- defData(varname = "m_effect", formula = 0, variance = 1)

dd_region <- genData(20, region_def, id = "region")
dd_mouse  <- genData(8, mouse_def, id = "mouse")

dd <- genCrossed(
  dd_mouse,
  dd_region,
  id = "mouse_region_id"
)