我对 in 的评估迷失by
了data.table
。将功能合并到一个功能中的正确方法是LJ
什么LJ2
?
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)