# merge

0th

Percentile

##### Merge Two Data Tables

Relatively quick merge of data tables based on common keys.

Keywords
data
##### Usage
## S3 method for class 'data.table':
merge(x, y, all = FALSE, all.x = all, all.y = all, ...)
##### Arguments
x, y
data tables.
all
logical; all = L is shorthand for all.x = L and all.y = L.
all.x
logical; if TRUE, then extra rows will be added to the output, one for each row in x that has no matching row in y. These rows will have 'NA's in those columns that are usually filled w
all.y
logical; analogous to all.x above.
...
Not used at this time.
##### Details

Keys must be in the same order.

##### Value

• A data table based on the merged data tables, sorted by the common keys.

data.table, merge

##### Aliases
• merge.data.table
##### Examples
(dt1 <- data.table(A = letters[1:10], X = 1:10, key = "A"))
(dt2 <- data.table(A = letters[5:14], Y = 1:10, key = "A"))
merge(dt1, dt2)
merge(dt1, dt2, all = TRUE)

(dt1 <- data.table(A = letters[rep(1:3, 2)], X = 1:6, key = "A"))
(dt2 <- data.table(A = letters[rep(2:4, 2)], Y = 6:1, key = "A"))
merge(dt1, dt2)

(dt1 <- data.table(A = c(rep(1L, 5), 2L), B = letters[rep(1:3, 2)], X = 1:6, key = "A,B"))
(dt2 <- data.table(A = c(rep(1L, 5), 2L), B = letters[rep(2:4, 2)], Y = 6:1, key = "A,B"))
merge(dt1, dt2)
Documentation reproduced from package data.table, version 1.4.1, License: GPL

### Community examples

Looks like there are no examples yet.