[datatable-help] rbindlist(x) doesn't behave like rbind for all null lists
caneff at gmail.com
caneff at gmail.com
Tue Oct 29 20:17:43 CET 2013
Yes I can. I suppose the actual inconsistency lies in rbind.data.frame
then. It doesn't follow the same guarantee of "always outputs a
data.table". Otherwise
rbind(NULL, NULL)
and
data.frame(NULL)
would have the same result.
Maybe I would wonder if calling it a "null data.table" is the right
terminology, since it really is just an empty data.table. A null
data.table would imply that is.null would be true.
On Tue Oct 29 2013 at 2:11:30 PM, Eduard Antonyan <eduard.antonyan at gmail.com>
wrote:
> perhaps you can use length() == 0 instead of is.null() for your purposes
>
>
> On Tue, Oct 29, 2013 at 1:01 PM, Eduard Antonyan <
> eduard.antonyan at gmail.com> wrote:
>
> 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/dbc1758e/attachment.html>
More information about the datatable-help
mailing list