nm, looks like the above is the doing of `ifelse` and is a different issue
On Fri, May 17, 2013 at 5:45 PM, Eduard Antonyan <[email protected]>wrote: > Actually, looking at this example: > > > dd[, ifelse(a < 2, a, integer(0)), by = a] > a V1 > 1: 1 1 > 2: 2 NA > 3: 3 NA > > 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. > > > On Fri, May 17, 2013 at 5:36 PM, Gabor Grothendieck < > [email protected]> wrote: > >> Yes, I understand all that but its not inevitable that it had to be >> that way. If we perform a computation that results in a list with >> zero length component then the corresponding row won't show up but >> another possibility might have been that it would show up filled in >> with NAs. >> >> At any rate, the question remains whether this behavior is intended or >> not. >> >> >> >> >> >> On Fri, May 17, 2013 at 4:47 PM, Eduard Antonyan >> <[email protected]> wrote: >> > well numeric(0) is no data, but because in the first case there was >> other >> > data to output and you also asked to output `y`, what else was it >> supposed >> > to do? ( it might help to look at the output of c(numeric(0), >> numeric(0)) ) >> > >> > >> > On Fri, May 17, 2013 at 3:38 PM, Gabor Grothendieck >> > <[email protected]> wrote: >> >> >> >> In the first case it replaced the zero length component with NA and in >> >> the second case it did not. Why the difference? >> >> >> >> On Fri, May 17, 2013 at 4:33 PM, Eduard Antonyan >> >> <[email protected]> wrote: >> >> > 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 >> >> > <[email protected]> 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 >> >> >> [email protected] >> >> >> >> >> >> >> >> >> >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Statistics & Software Consulting >> >> GKX Group, GKX Associates Inc. >> >> tel: 1-877-GKX-GROUP >> >> email: ggrothendieck at gmail.com >> > >> > >> >> >> >> -- >> Statistics & Software Consulting >> GKX Group, GKX Associates Inc. >> tel: 1-877-GKX-GROUP >> email: ggrothendieck at gmail.com >> > >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
