Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@

17. Non-UTF8 strings were not always sorted correctly on Windows (a regression in v1.12.0), [#3397](https://github.com/Rdatatable/data.table/issues/3397) [#3451](https://github.com/Rdatatable/data.table/issues/3451). Thanks to @shrektan for reporting and fixing.

18. `cbind` with a null (0-column) `data.table` now works as expected, [#3445](https://github.com/Rdatatable/data.table/issues/3445). Thanks to @mb706 for reporting.

#### NOTES

1. When upgrading to 1.12.0 some Windows users might have seen `CdllVersion not found` in some circumstances. We found a way to catch that so the [helpful message](https://twitter.com/MattDowle/status/1084528873549705217) now occurs for those upgrading from versions prior to 1.12.0 too, as well as those upgrading from 1.12.0 to a later version. See item 1 in notes section of 1.12.0 below for more background.
Expand Down
8 changes: 4 additions & 4 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ data.table <-function(..., keep.rownames=FALSE, check.names=FALSE, key=NULL, str
.Call(CcopyNamedInList,x) # to maintain pre-Rv3.1.0 behaviour, for now. See test 548.2. TODO: revist
# TODO Something strange with NAMED on components of `...` to investigate. Or, just port data.table() to C.

n <- length(x)
if (n < 1L)
if (length(x) < 1L)
return( null.data.table() )
# fix for #5377 - data.table(null list, data.frame and data.table) should return null data.table. Simple fix: check all scenarios here at the top.
if (identical(x, list(NULL)) || identical(x, list(list())) ||
identical(x, list(data.frame(NULL))) || identical(x, list(data.table(NULL)))) return( null.data.table() )
nd = name_dots(...)
if (any(nocols<-sapply(x, NCOL)==0L)) { tt=!nocols; x=x[tt]; nd=lapply(nd,'[',tt); } # data.table(data.table(), data.table(a=integer())), #3445
vnames = nd$vnames
# We will use novname later to know which were explicitly supplied in the call.
novname = nd$novname
novname = nd$novname # novname used later to know which were explicitly supplied in the call
n <- length(x)
if (length(vnames) != n) stop("logical error in vnames") # nocov
# cast to a list to facilitate naming of columns with dimension --
# unlist() at the end automatically handles the need to "push" names
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# identical(TRUE,x)
# See PR#3421 for timings.
# It was changed in R so that isTRUE(c(a=TRUE)) returned TRUE: https://github.com/wch/r-source/commit/828997ac6ecfb73aaa0aae9d1d0584a4ffc50881#diff-b41e3f9f1d389bb6f7a842cd5a3308b8
if (base::getRversion() < "3.5.0") {
if (base::getRversion() < "3.5.0") {
isTRUE = function(x) is.logical(x) && length(x)==1L && !is.na(x) && x # backport R's new implementation of isTRUE
isFALSE = function(x) is.logical(x) && length(x)==1L && !is.na(x) && !x # backport isFALSE that was added in R 3.5.0
}
Expand Down
7 changes: 7 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -13856,6 +13856,13 @@ if (.Platform$OS.type == 'windows') local({
Sys.setlocale('LC_CTYPE', lc_ctype)
})

# cbind of zero-row data.table with empty data.table messed up columns, #3445
test(2012.1, data.table(data.table(), data.table(a=integer())), data.table(a=integer()))
test(2012.2, data.table(data.frame(), data.table(a=integer())), data.table(a=integer()))
test(2012.3, data.table(data.frame(), data.frame(a=integer())), data.table(a=integer()))
dt = as.data.table(iris)
test(2012.4, cbind(data.table(), dt[0]), dt[0])


###################################
# Add new tests above this line #
Expand Down