[datatable-help] "Within" Reversed column order?

Matthew Dowle mdowle at mdowle.plus.com
Mon May 28 12:09:38 CEST 2012


Not sure why but it seems to be consistent with base data.frame :

> DF = data.frame(a=1:3,b=4:6)
> within(DF,{c=a*b;d=a+b})
  a b d  c
1 1 4 5  4
2 2 5 7 10
3 3 6 9 18
> 

I don't mind it being raised as a bug in data.table and we'll fix it and
and add to FAQ 2.17 as another difference to data.frame. Or maybe it
would be clearer to remove within.data.table(). Do we need it?

Matthew

On Sat, 2012-05-26 at 10:47 -0700, Yike Lu wrote:
> I noticed this when I moved from chained [,:=] to within...
> 
> When adding columns, the columns are added in reverse order of the
> assignment order, e.g.
> 
> DT= data.table(a=1:10, b=2:11)
> 
> within(DT,
> {
> c=a*b
> d=a+b
> }
> )
> 
> # d appears before c in the column ordering.
> 
> While this isn't a huge deal, it is annoying as I often create data.tables
> with many columns and the ordering is intentional, to make the data easier
> to read.
> 
> Is this a bug?
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Within-Reversed-column-order-tp4631464.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list