Thinking through this, the reasons I use within:
1) Avoid chained [:=]
2) Better semantics than transform (i.e, avoid commas, have one large expression block)

However, if i do:

X=within(X, {...}) #versus
transform(X)

is transform then more efficient?

I'm all for keeping consistency with data.frame, and I assume that's the real reason these functions are here.

Perhaps this is really a case where we want an efficient multi-update instead of a properly ordered within?
Or perhaps an overload on transform that allows {expr}.

On 5/28/2012 6:09 AM, Matthew Dowle wrote:
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
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to