I don't think you can reference them by name, but if they are in a list you can reference them by index, e.g.
dt[,colnames(dt)[3:5],with=FALSE] will get you height, weight and shoe.size or alternatively dt[,.SD,.SDcols=colnames(dt)[3:5]] does the same thing On Mon, Feb 9, 2015 at 7:08 PM, Farrel Buchinsky <[email protected]> wrote: > So lets say one has a data.table with the following columns > > first.name, last.name, height, weight, shoe.size, eye.color, hair.length, > appendage.size, ear.length > > If one wanted to just include weight through hair.length one would have to > go something such as this > > dt[,list(weight, shoe.size, eye.color, hair.length)] > > Is there a way to do something along the lines of > > dt[,list(weight...hair.length)] > > If so, can you direct me to the documentation? If not can you build it? Is > it difficult? Some data.tables have many columns. > > Thanking you in anticipation. > > Farrel > > _______________________________________________ > datatable-help mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
