[datatable-help] zero length list component in j
Eduard Antonyan
eduard.antonyan at gmail.com
Fri May 17 22:33:28 CEST 2013
Maybe I'm missing smth, but what else did you expect? Looks like it did
it's best to compensate for the user not supplying full data in the first
example, and there really was nothing to do in the second one.
On Fri, May 17, 2013 at 3:27 PM, Gabor Grothendieck <ggrothendieck at gmail.com
> wrote:
> Is this intended? If we use j = list(x = "X", y = numeric(0)) we get
> a row but if we use just list(y = numeric(0)) then we do not get a
> row. In the first case it filled in the zero length component with NA
> and in the second case it just omitted the row entirely:
>
> > dd <- data.table(a = 1:3)
> > dd
> a
> 1: 1
> 2: 2
> 3: 3
> > dd[, list(x = "X", y = numeric(0)), by = a]
> a x y
> 1: 1 X NA
> 2: 2 X NA
> 3: 3 X NA
> > dd[, list(y = numeric(0)), by = a]
> Empty data.table (0 rows) of 2 cols: a,y
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
> _______________________________________________
> 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/20130517/dfec3514/attachment.html>
More information about the datatable-help
mailing list