[datatable-help] Syntax: ag["M",age]$age ?

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Jan 20 16:46:03 CET 2012


Hi,

On Fri, Jan 20, 2012 at 7:19 AM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> Good question. I was thinking of changing it - in the special case that j
> is a single name, it would return a vector. If the grouping columns were
> needed just wrap the name with list(). We have a similar rule for i when
> that's a single name.  The reason the grouping columns are always returned
> was for consistency when there are multiple groups in i you probably want
> to know which refer to which and we don't want a different type to be
> returned depending on data passed to i.
> It would be a non-backwards compatible change but we could return the old
> bahaviour via an global option.
> I get frustrated by it too, and it would be more efficient in those cases
> as well.

Instead of special casing syntax like you suggest, doesn't this ave a
natural "fit" with w/ the "idiomatic R" `drop=TRUE/FALSE` business?

I know it's not currently supported in data.table, but you could
imagine always defaulting to FALSE, then in the single column case,
you could do:

 ag["M",age, drop=TRUE]

or some such.

-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