[datatable-help] aggregation error under 1.5.3

Matthew Dowle mdowle at mdowle.plus.com
Wed Apr 13 01:20:23 CEST 2011


Yes that is known bug #1294. Haven't had a chance to fix it yet, but
it's quite an annoying one. Steve's workaround is correct in the
meantime.
Matthew

On Tue, 2011-04-12 at 15:51 -0400, Steve Lianoglou wrote:
> 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
> 




More information about the datatable-help mailing list