<div dir="ltr">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.<div><br></div><div>dt[,colnames(dt)[3:5],with=FALSE]</div><div><br></div><div>will get you height, weight and shoe.size</div><div><br></div><div>or alternatively</div><div><br></div><div>dt[,.SD,.SDcols=colnames(dt)[3:5]]</div><div><br></div><div>does the same thing</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 9, 2015 at 7:08 PM, Farrel Buchinsky <span dir="ltr"><<a href="mailto:fjbuch@gmail.com" target="_blank">fjbuch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So lets say one has a data.table with the following columns<div><br></div><div><a href="http://first.name" target="_blank">first.name</a>, <a href="http://last.name" target="_blank">last.name</a>, height, weight, shoe.size, eye.color, hair.length, appendage.size, ear.length</div><div><br></div><div>If one wanted to just include weight through hair.length one would have to go something such as this</div><div><br></div><div>dt[,list(<span style="font-size:13.1999998092651px">weight, shoe.size, eye.color, hair.length)]</span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">Is there a way to do something along the lines of</span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">dt[,list(</span><span style="font-size:13.1999998092651px">weight...hair.length)]</span><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">If so, can you direct me to the documentation? If not can you build it? Is it difficult? Some data.tables have many columns.</span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">Thanking you in anticipation.</span></div><span class="HOEnZb"><font color="#888888"><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">Farrel</span></div></font></span></div>
<br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br></blockquote></div><br></div>