<div dir="ltr"><div style>nm, looks like the above is the doing of `ifelse` and is a different issue</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 5:45 PM, Eduard Antonyan <span dir="ltr"><<a href="mailto:eduard.antonyan@gmail.com" target="_blank">eduard.antonyan@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Actually, looking at this example:<div><br></div><div><div>> dd[, ifelse(a < 2, a, integer(0)), by = a]</div>
<div>   a V1</div><div>1: 1  1</div><div>2: 2 NA</div><div>3: 3 NA</div></div><div><br></div>
<div>I don't quite understand the output. I don't have a coherent story for this and your examples - either your second example should print NA's or this one shouldn't have the last two rows imo.</div>
</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 5:36 PM, Gabor Grothendieck <span dir="ltr"><<a href="mailto:ggrothendieck@gmail.com" target="_blank">ggrothendieck@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, I understand all that but its not inevitable that it had to be<br>
that way.  If we perform a computation that results in a list with<br>
zero length component then the corresponding row won't show up but<br>
another possibility might have been that it would show up filled in<br>
with NAs.<br>
<br>
At any rate, the question remains whether this behavior is intended or not.<br>
<br>
<br>
<br>
<br>
<br>
On Fri, May 17, 2013 at 4:47 PM, Eduard Antonyan<br>
<div><div><<a href="mailto:eduard.antonyan@gmail.com" target="_blank">eduard.antonyan@gmail.com</a>> wrote:<br>
> well numeric(0) is no data, but because in the first case there was other<br>
> data to output and you also asked to output `y`, what else was it supposed<br>
> to do? ( it might help to look at the output of c(numeric(0), numeric(0)) )<br>
><br>
><br>
> On Fri, May 17, 2013 at 3:38 PM, Gabor Grothendieck<br>
> <<a href="mailto:ggrothendieck@gmail.com" target="_blank">ggrothendieck@gmail.com</a>> wrote:<br>
>><br>
>> In the first case it replaced the zero length component with NA and in<br>
>> the second case it did not.  Why the difference?<br>
>><br>
>> On Fri, May 17, 2013 at 4:33 PM, Eduard Antonyan<br>
>> <<a href="mailto:eduard.antonyan@gmail.com" target="_blank">eduard.antonyan@gmail.com</a>> wrote:<br>
>> > Maybe I'm missing smth, but what else did you expect? Looks like it did<br>
>> > it's<br>
>> > best to compensate for the user not supplying full data in the first<br>
>> > example, and there really was nothing to do in the second one.<br>
>> ><br>
>> ><br>
>> ><br>
>> > On Fri, May 17, 2013 at 3:27 PM, Gabor Grothendieck<br>
>> > <<a href="mailto:ggrothendieck@gmail.com" target="_blank">ggrothendieck@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Is this intended?  If we use j = list(x = "X", y = numeric(0)) we get<br>
>> >> a row but if we use just list(y = numeric(0)) then we do not get a<br>
>> >> row.  In the first case it filled in the zero length component with NA<br>
>> >> and in the second case it just omitted the row entirely:<br>
>> >><br>
>> >> > dd <- data.table(a = 1:3)<br>
>> >> > dd<br>
>> >>    a<br>
>> >> 1: 1<br>
>> >> 2: 2<br>
>> >> 3: 3<br>
>> >> > dd[, list(x = "X", y = numeric(0)), by = a]<br>
>> >>    a x  y<br>
>> >> 1: 1 X NA<br>
>> >> 2: 2 X NA<br>
>> >> 3: 3 X NA<br>
>> >> > dd[, list(y = numeric(0)), by = a]<br>
>> >> Empty data.table (0 rows) of 2 cols: a,y<br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> Statistics & Software Consulting<br>
>> >> GKX Group, GKX Associates Inc.<br>
>> >> tel: 1-877-GKX-GROUP<br>
>> >> email: ggrothendieck at <a href="http://gmail.com" target="_blank">gmail.com</a><br>
>> >> _______________________________________________<br>
>> >> datatable-help mailing list<br>
>> >> <a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a><br>
>> >><br>
>> >><br>
>> >> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
>> ><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> Statistics & Software Consulting<br>
>> GKX Group, GKX Associates Inc.<br>
>> tel: 1-877-GKX-GROUP<br>
>> email: ggrothendieck at <a href="http://gmail.com" target="_blank">gmail.com</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
Statistics & Software Consulting<br>
GKX Group, GKX Associates Inc.<br>
tel: 1-877-GKX-GROUP<br>
email: ggrothendieck at <a href="http://gmail.com" target="_blank">gmail.com</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>