From 7353bc656739ad31c10379cdf746539d7bcbabf4 Mon Sep 17 00:00:00 2001 From: Benjamin Schwendinger Date: Sun, 31 Mar 2024 19:03:24 +0200 Subject: [PATCH] finish todo of #5857 --- R/merge.R | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/R/merge.R b/R/merge.R index 8062d91fc..ea53df3f2 100644 --- a/R/merge.R +++ b/R/merge.R @@ -96,21 +96,7 @@ merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FAL if (all.y && nrow(y)) { # If y does not have any rows, no need to proceed # Perhaps not very commonly used, so not a huge deal that the join is redone here. missingyidx = y[!x, which=TRUE, on=by, allow.cartesian=allow.cartesian] - # TO DO: replace by following once #5446 is merged - # if (length(missingyidx)) dt = rbind(dt, y[missingyidx], use.names=FALSE, fill=TRUE, ignore.attr=TRUE) - if (length(missingyidx)) { - yy = y[missingyidx] - othercolsx = setdiff(nm_x, by) - if (length(othercolsx)) { - # create NA rectangle with correct types and attributes of x to cbind to y - tmp = rep.int(NA_integer_, length(missingyidx)) - # TO DO: use set() here instead.. - yy = cbind(yy, x[tmp, othercolsx, with = FALSE]) - } - # empty data.tables (nrow =0, ncol>0) doesn't skip names anymore in new rbindlist - # takes care of #24 without having to save names. This is how it should be, IMHO. - dt = rbind(dt, yy, use.names=FALSE) - } + if (length(missingyidx)) dt = rbind(dt, y[missingyidx], use.names=FALSE, fill=TRUE, ignore.attr=TRUE) } # X[Y] syntax puts JIS i columns at the end, merge likes them alongside i. newend = setdiff(nm_y, by.y)