mergeDT: mergeDT()

Description Usage Arguments Examples

Description

Merges two data.tables using

Usage

1
2
mergeDT(DT1 = NULL, DT2 = NULL, keys = NULL, keepCols = NULL,
  deleteCols = NULL)

Arguments

DT1

a data.table

DT2

a data.table

keys

a character vector of one or more columns to join on between DT1 or DT2. If you have already used data.table::setkey() to set the keys for DT1 and DT2 and those keys are identical, and you do not specify the keys argument, the join will be performed on those columns.

keepCols

a character vector of column names NOT to delete. You may specify keepCols or deleteCols but NOT BOTH.

deleteCols

a character vector of column names to delete. You may specify keepCols or deleteCols but NOT BOTH.

Examples

1
2
3
4
5
6
7
Merging two data.tables where we specify the key in \code{mergeDT}:
mergeDT(DT1, DT2, keys = "common_id")

Setting keys first, then merging two data.tables:
setkey(DT1, common_id)
setkey(DT2, common_id)
mergeDT(DT1, DT2)

jakesherman/jakemisc documentation built on May 18, 2019, 9:08 a.m.