mergeWithColPrioritization: Merger of two data.tables with repeated columns with...

Description Usage Arguments Value Examples

View source: R/mergeWithColPrioritization.R

Description

Merger (outer join) of two data.tables with repeated columns where we want to prioritize the values of one data.table.

Usage

1
mergeWithColPrioritization(dt_prior, dt_other, v_s_keys)

Arguments

dt_prior

data.table for which has prioritized columns.v_s_keys must be columns in dt_prior.

dt_other

data.table wich we want to merge. v_s_keys must be columns in dt_other.

v_s_keys

character vector of column names to merge by.

Value

data.table of prioritized merger of dt_prior and dt_other.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(data.table)
i_num <- 3
dt_prior <- data.table( id = 1:i_num,
                        var1 = letters[1:i_num],
                        var2 = 111)
dt_other <- data.table( id = 1:(i_num+2),
                        var1 = paste0(letters[10 + 1:(i_num+2)],letters[10 + 1:(i_num+2)]) ,
                        var3 = -999)
v_s_keys <- "id"

dt_prior
dt_other
mergeWithColPrioritization(dt_prior, dt_other,v_s_keys )

AlejandroKantor/akmisc documentation built on May 5, 2019, 3:51 a.m.