[datatable-help] rbindlist(x) doesn't behave like rbind for all null lists

Eduard Antonyan eduard.antonyan at gmail.com
Tue Oct 29 19:01:14 CET 2013


This is by design, and is not a bug.

If you try

    data.table:::.rbind.data.table(NULL, NULL)

in version 1.8.10 you will also get a 0-size data.table in agreement with
rbindlist (if you try the above in the very latest version, you will get an
error, and I may change that to be same as 1.8.10 - but it doesn't matter
much, as you can't get there unless you use ":::", and then all bets are
off anyway). Both are supposed to always return data.tables.

The reason you're getting something else with rbind(NULL, NULL) is because
those NULL's are not data.tables, so a *different* rbind is called, which
has nothing to do with data.table.



On Tue, Oct 29, 2013 at 12:47 PM, Chris Neff <caneff at gmail.com> wrote:

> Simple thing:
>
> dt <- rbindlist(list(NULL, NULL)) #dt is a data.table with 0 rows and
> columns
>
> is.null(dt) # Prints false
>
> d <- rbind(NULL, NULL)  #d is NULL
>
> is.null(d) # Prints true
>
>
> I would expect the two to be equivalent.  This bit me when I was relying
> on !is.null(dt) before assigning other columns in the data.table.
>  rbindlist should return NULL in this case I would think.
>
> Is this working as intended? Or should I file a bug?
>
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131029/8a7a5ecb/attachment.html>


More information about the datatable-help mailing list