egdt: Expand grid of data.tables

View source: R/egdt.R

egdtR Documentation

Expand grid of data.tables

Description

Expand grid of data.tables

Usage

egdt(dt1, dt2, quiet)

Arguments

dt1

a data.table.

dt2

another data.table.

quiet

The default is to give some information along the way on what data is found. But consider setting this to TRUE for non-interactive use. Default can be configured using NMdataConf.

Details

Merging works mostly similarly for data.table and data.table. However, for data.table the merge must be done by one or more columns. This means that the convenient way to expand all combinations of all rows in two data.frames is not available for data.tables. This functions provides that functionality. It always returns data.tables.

Value

a data.table that expands combinations of rows in dt1 and dt2.

Examples

df1 <- data.frame(a=1:2,b=3:4)
df2 <- data.frame(c=5:6,d=7:8)
merge(df1,df2)
library(data.table)
## This is not possible
## Not run: 
merge(as.data.table(df1),as.data.table(df2),allow.cartesian=TRUE)

## End(Not run)
## Use egdt instead
egdt(as.data.table(df1),as.data.table(df2))

NMdata documentation built on Nov. 11, 2023, 5:07 p.m.