<font face="courier new,monospace"><div><font face="courier new,monospace">Hi--</font></div><div><font face="courier new,monospace"><br></font></div></font><font face="courier new,monospace">You can use the subset() command with the select= option; not sure it's the best solution, though.<br>
</font><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">Timothee<br></font></div><div><div class="gmail_quote">
<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Wed, Jul 20, 2011 at 12:26 PM, Chris Neff <span dir="ltr"><<a href="mailto:caneff@gmail.com">caneff@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I have a function where I pass a data frame and some variable names to calculate statistics on. However, I am at a loss as to how to write it correctly so that both data.frame and data.table work with it. If I have:<div>
<br>
</div><div>DF = data.frame(x=1:10,y=2:11,z=3:12)</div><div><br></div><div>DT = data.table(DF)</div><div><br></div><div>var.names = c("x","y")</div><div><br></div><div><br></div><div>I can do the following things to subset:</div>
<div><br></div><div>DT[,var.names,with=FALSE]</div><div>DF[,var.names]</div><div><br></div><div><br></div><div>but of course DT[,var.names] won't give me back what I want, and DF[,var.names,with=FALSE] returns an error because with doesn't exist there. So how do I do this?</div>
<div><br></div><div>Thanks,</div><div>-Chris</div><font color="#888888"><div><br></div><div><br></div>
</font><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>
<br></blockquote></div><br></div>