Skip to content

Commit 2866182

Browse files
return output invisibly for set* functions
1 parent c1e33b9 commit 2866182

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

R/mergelist.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cbindlist_impl_ = function(l, copy) {
99
}
1010

1111
cbindlist = function(l) cbindlist_impl_(l, copy=TRUE)
12-
setcbindlist = function(l) cbindlist_impl_(l, copy=FALSE)
12+
setcbindlist = function(l) invisible(cbindlist_impl_(l, copy=FALSE))
1313

1414
# when 'on' is missing then use keys, used only for inner and full join
1515
onkeys = function(x, y) {
@@ -352,7 +352,7 @@ mergelist = function(l, on, cols=NULL, how=c("left", "inner", "full", "right", "
352352
setmergelist = function(l, on, cols=NULL, how=c("left", "inner", "full", "right", "semi", "anti", "cross"), mult, join.many=getOption("datatable.join.many")) {
353353
if (missing(how) || is.null(how))
354354
how = match.arg(how)
355-
mergelist_impl_(l, on, cols, how, mult, join.many, copy=FALSE)
355+
invisible(mergelist_impl_(l, on, cols, how, mult, join.many, copy=FALSE))
356356
}
357357

358358
# Previously, we had a custom C implementation here, which is ~2x faster,

inst/tests/mergelist.Rraw

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,3 +1314,9 @@ local({
13141314
test(301.01, data.table(x=unique(dt$x)), ans) ## OK
13151315
test(301.02, fdistinct(dt, on="x"), ans) ## force sort=TRUE for the moment
13161316
})
1317+
1318+
# output from set* functions is returned invisibly
1319+
l = list(data.table(a=1:3), data.table(b=2:4))
1320+
test(302.1, capture.output(setcbindlist(l)), character()) # NB test(notOutput=) doesn't work since print() is explicitly run
1321+
l = list(data.table(a=1:3), data.table(a=2:4))
1322+
test(302.2, capture.output(setmergelist(l, on='a')), character())

0 commit comments

Comments
 (0)