Skip to content

Commit

Permalink
output from merge
Browse files Browse the repository at this point in the history
feature request Rdatatable#4677
  • Loading branch information
ycphs committed Sep 22, 2020
1 parent be6c1fc commit a206818
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/merge.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FALSE, all.x = all,
all.y = all, sort = TRUE, suffixes = c(".x", ".y"), no.dups = TRUE, allow.cartesian=getOption("datatable.allow.cartesian"), ...) {
all.y = all, sort = TRUE, suffixes = c(".x", ".y"), no.dups = TRUE, allow.cartesian=getOption("datatable.allow.cartesian"), info = FALSE, ...) {
if (!sort %in% c(TRUE, FALSE))
stop("Argument 'sort' should be logical TRUE/FALSE")
if (!no.dups %in% c(TRUE, FALSE))
stop("Argument 'no.dups' should be logical TRUE/FALSE")
if (!info %in% c(TRUE, FALSE))
stop("Argument 'info' should be logical TRUE/FALSE")
class_x = class(x)
if (!is.data.table(y)) {
y = as.data.table(y)
Expand Down Expand Up @@ -98,5 +100,15 @@ merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FAL

# retain custom classes of first argument that resulted in dispatch to this method, #1378
setattr(dt, "class", class_x)
dt
if(info) {
cat("Rows in x:" , x[, .N, verbose = F], "\n")
cat("Rows in y:" , y[, .N, verbose = F], "\n")
cat("Matched rows:" , y[x, nomatch = NULL, on = by, allow.cartesian =
allow.cartesian, verbose = F][, .N, verbose = F], "\n")
cat("Total rows after merge:" , dt[, .N, verbose = F], "\n")
dt
} else {
dt
}

}

0 comments on commit a206818

Please sign in to comment.