[datatable-help] Comma-separated columns in by break if there are spaces

Christoph Jäckel christoph.jaeckel at wi.tum.de
Sat Mar 31 15:03:03 CEST 2012


Hi together,

I use spaces when I separate columns in the by-argument, but with version
1.8.0 that does not work anymore:

library(data.table)
DT <- data.table(A = rep(letters[1:10], each=5),
                 B = rep(1:10, times=5),
                 C = rnorm(50))
DT[, .N, by="A, B"] #does not work, but used to work before
DT[, .N, by="A,B"]  #does work

Is this on purpose? Or is this a minor bug, probably introduced when bug
#1880 was fixed (see NEWS of v1.8.0):

* 'by' was failing (bug #1880) when passed character column names where
one or more included a space. So, this now works :
    DT[,sum(v),by="column 1"]
and j retains spaces in column names rather than replacing spaces with
"."; e.g.,
    DT[,list("a b"=1)]
Thanks to Yang Zhang for reporting. Tests added. As before, column names
may be back ticked in the usual R way (in i, j and by); e.g.,
    DT[,sum(`nicely named var`+1),by=month(`long name for date column`)]

If it's the latter, let me know. I'll raise a bug report.

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120331/f6acdf9c/attachment.html>


More information about the datatable-help mailing list