[datatable-help] variable column names
Matthew Dowle
mdowle at mdowle.plus.com
Wed Apr 24 22:54:17 CEST 2013
where ... is eval(myid)
iigc
> Or:
> DT[,lapply(.SD,sum),by=...,.SDcols=myvars]
>
>> with = FALSE will let you use literal column names
>>
>>
>> On Wed, Apr 24, 2013 at 3:29 PM, Sam Steingold <sds at gnu.org> wrote:
>>
>>> What do I do if I want to operate on several columns?
>>> E.g.,
>>> --8<---------------cut here---------------start------------->8---
>>> length(names(dt)) = 25
>>> myvars = c("col1","col4","col7")
>>> myid = "user"
>>> setkeyv(dt,myid)
>>> --8<---------------cut here---------------end--------------->8---
>>> and I want to summarize columns in myvars by myid.
>>> the point is that nowhere in the code the literal "col4" or "user" may
>>> appear.
>>>
>>> Thanks.
>>>
>>> --
>>> Sam Steingold (http://sds.podval.org/) on Ubuntu 12.10 (quantal) X
>>> 11.0.11300000
>>> http://www.childpsy.net/ http://ffii.org http://palestinefacts.org
>>> http://openvotingconsortium.org http://camera.org http://jihadwatch.org
>>> The difference between genius and stupidity is that genius has its
>>> limits.
>>> _______________________________________________
>>> 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
>>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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