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

Steve Lianoglou mailinglist.honeypot at gmail.com
Sat Jan 21 16:48:10 CET 2012


Howdy,

On Fri, Jan 20, 2012 at 8:43 PM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> Hi Steve,
>
> Adding 'drop' does sound better. The original gripe was its default, not
> drop itself I suppose. It might be handy when j isn't a single name,
> too; e.g.,
>
>> DT
>     a v
> [1,] A 1
> [2,] A 2
> [3,] B 3
> [4,] B 4
> [5,] B 5
>> setkey(DT,a)
>> DT[c("A","B"),sum(v)]$V1         # current
> [1]  3 12
>> DT[c("A","B"),sum(v),drop=TRUE]  # future
> [1]  3 12
>
> When j doesn't return a vector and drop=TRUE was supplied then it should
> warn?; e.g.,
>
> DT[c("A","B"),list(sum(v),min(v)),drop=TRUE]   # warning, ignoring drop

It *feels* like it should warn, right?

I double checked to see what base R data structures do (matrices and
data.frames) and they don't warn in this scenario.

So, I guess while I'm in favor of firing the warning in these
situations, I think it's probably better to just do as base R does.

-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