[datatable-help] aggregation error under 1.5.3

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue Apr 12 21:51:50 CEST 2011


Hi,

On Tue, Apr 12, 2011 at 3:35 PM, Johann Hibschman
<jhibschman+r at gmail.com> wrote:
> I finally managed to upgrade to 1.5.3, but now I'm seeing errors when
> aggregating data tables:
>
>  > d <- data.table(a=as.integer(c(1, 1, 2, 2, 3, 3)), b=1:6 %% 2, c=1:6)
>  > d[b==1,list(c=sum(c)),by=list(a)]
>  Error in i[1, ivars, with = FALSE] : incorrect number of dimensions
>
> Does anyone know what's going on with this?

Not off the top of my head (although I'm sure Matthew will figure it
out quite quickly).

In the meantime, you could do this like so:

R> d[b==1][, list(c=sum(c)), by=list(a)]

If your `d` data.table is large, though, you might consider:

R> key(d) <- c('b', 'a')
R> d[J(1)][, list(c=sum(c)), by=list(a)]

Also, I'm using the development version of data.table from R-forge,
but I don't think that'll make a difference in this case.

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the datatable-help mailing list