I am lost with evaluation of by
in data.table
. What will be correct way to merge functionality of LJ
and LJ2
into one function?
LJ <- function(dt_x_, dt_y_, by_)
{
merge(
dt_x_,
dt_y_,
by = eval(substitute(by_)), all.x = TRUE, sort = FALSE)
}
LJ2 <- function(dt_x_, dt_y_, by_)
{
merge(
dt_x_,
dt_y_,
by = deparse(substitute(by_)), all.x = TRUE, sort = FALSE)
}
LJ(
data.table(A = c(1,2,3)),
data.table(A = c(1,2,3), B = c(11,12,13)),
"A")
LJ2(
data.table(A = c(1,2,3)),
data.table(A = c(1,2,3), B = c(11,12,13)),
A)