Binding integer64 with integer/numeric works silently and correctly, whereas binding IDate with Date fails and so does binding of attribute cols where one/more tables are empty (0-rows).
integer 64 case:
require(data.table) # 1.12.2 current CRAN version, but I don't think things change with current devel)
require(bit64)
ll <- list(data.table(a=1, b=as.integer64(2)), data.table(a=2, b=1))
str(rbindlist(ll))
# Classes ‘data.table’ and 'data.frame': 2 obs. of 2 variables:
# $ a: num 1 2
# $ b:integer64 2 1
# - attr(*, ".internal.selfref")=<externalptr>
The 2nd element's col b seems to be implicitly converted to integer64 type without a message/warning.
IDate case
ll <- list(data.table(a=1, b=as.IDate(Sys.Date())), data.table(a=2, b=Sys.Date()))
rbindlist(ll)
# Error in rbindlist(ll) :
# Class attribute on column 2 of item 2 does not match with column 2 of item 1.
First element's b column is IDate and 2nd is Date and there's an error.
0-row data.table case:
ll <- list(data.table(a=1, b=Sys.time()), data.table(a=numeric(0), b=numeric(0)))
rbindlist(ll)
# Error in rbindlist(ll) :
# Class attribute on column 2 of item 2 does not match with column 2 of item 1.
Even if the empty table has a wrong type, it could be skipped as it doesn't really make it to the final table. (This used to work in previous versions when fill=TRUE -- probably accidental).
In essence, I'd think it'd be immensely convenient to have an argument to ignore strict attributes check, e.g., ignore.attr=FALSE (together with a global option so that code that has been written with old+lenient behaviour work continue to work) which would simply retain the first element's class.
And if the default is to be strict, then, the first case should also error, for consistency.
Binding
integer64with integer/numeric works silently and correctly, whereas bindingIDatewithDatefails and so does binding of attribute cols where one/more tables are empty (0-rows).integer 64 case:
The 2nd element's col
bseems to be implicitly converted tointeger64type without a message/warning.IDate case
First element's
bcolumn isIDateand 2nd isDateand there's an error.0-row data.table case:
Even if the empty table has a wrong type, it could be skipped as it doesn't really make it to the final table. (This used to work in previous versions when
fill=TRUE-- probably accidental).In essence, I'd think it'd be immensely convenient to have an argument to ignore strict attributes check, e.g.,
ignore.attr=FALSE(together with a global option so that code that has been written with old+lenient behaviour work continue to work) which would simply retain the first element's class.And if the default is to be strict, then, the first case should also error, for consistency.