[datatable-help] v1.6.1 has just been submitted to CRAN
Matthew Dowle
mdowle at mdowle.plus.com
Tue Jun 28 00:18:55 CEST 2011
NEW FEATURES
o j's environment is now consistently reused so
that local variables may be set which persist
from group to group; e.g., incrementing a group
counter :
DT[,list(z,groupInd<-groupInd+1),by=x]
Thanks for Andreas Borg for reporting.
o A new symbol .BY is now available to j, containing 1 row
of the current 'by' variables, type list. 'by' variables
may also be used by name, and are now length 1 too. This
implements FR#1313. FAQ 2.10 has been updated accordingly.
Some examples :
DT[,sum(x)*.BY[[1]],by=eval(byexp)]
DT[,sum(x)*mylookuptable[J(y),z],by=y]
DT[,list(sum(unlist(.BY)),sum(z)),by=list(x,y%%2)]
o i may now be type list, and works the same as when i
is type data.table. This saves needing J() in as many
situations and may be a little more efficient. One
application is using .BY directly in j to join to a
relatively small lookup table, once per group, for space
and time efficiency. For example :
DT[,list(GROUPDATA[.BY]$name,sum(v)),by=grp]
BUG FIXES
o A 'by' character vector of column names now
works when there are less rows than columns; e.g.,
DT[,sum(x),by=key(DT)) where nrow(DT)==1.
Many thanks to Andreas Borg for report, proposed
fix and tests.
o Zero length columns in j no longer cause a crash in
some circumstances. Empty columns are filled with NA
to match the length of the longest column in j.
Thanks to Johann Hibschman for bug report #1431.
o unique.data.table now calls the same internal code
(in C) that grouping calls. This fixes a bug when
unique is called directly by user, and, NA exist
in the key (which might be quite rare). Thanks to
Damian Betebenner for bug report. unique should also
now be faster.
o Variables in calling scope can now be used in j when
i is logical or integer, fixing bug #1421.
USER-VISIBLE CHANGES
o ?data.table now documents that logical i is not quite
the same as i in [.data.frame. NA are treated as FALSE,
and DT[NA] returns 1 row of NA, unlike [.data.frame.
Three points have been added to FAQ 2.17. Thanks to
Johann Hibschman for highlighting.
o Startup banner now uses packageStartupMessage() so the
banner can be suppressed by those annoyed by banners,
whilst still being helpful to new users.
More information about the datatable-help
mailing list