Description Usage Arguments Examples
Only done when there if rows are uniquely identified by on Returns TARGET invisibly
1 | add_cols(TARGET, SOURCE, on, cols)
|
TARGET |
Target data.table |
SOURCE |
Source data.table |
on |
Which variables to join on. When unequal for TARGET and SOURCE, must be named vector, where the names correspond to the SOURCE. |
cols |
Which cols to add |
1 2 3 4 5 6 7 8 9 | TARGET = data.table(id = rep(1:10, each = 3))
SOURCE = data.table(id = 1:5)[, x := rnorm(.N)][, y := rnorm(.N)]
add_cols(TARGET, SOURCE, on = "id", cols = c("x", "y"))
TARGET[]
# Case of unequal named join vars
X = data.table(id0 = 1:10)
Y = data.table(id1 = 3:5)[, z := c("a", "b", "c")]
add_cols(X, Y, on = c("id1" = "id0"), cols = "z")
X[]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.