[datatable-help] Syntax: ag["M",age]$age ?
Matthew Dowle
mdowle at mdowle.plus.com
Fri Jan 20 13:19:06 CET 2012
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.
n
>
> When I want the vector of the males, I use the following:
>
> ag =
> data.table(gender=rep(c("M","F"),10),age=seq(10,20,length.out=20),key="gender")
> ag["M",age]$age
>
> Just for the elegance: did I miss some method to get this without the
> trailing $age?
>
> Dieter
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Syntax-ag-M-age-age-tp4313006p4313006.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