<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Thank you for clarifying this! I was getting stuck on this. Yes the syntax and speedup are very nice indeed. I am dealing with 10 million row tables so it is very useful for me.</span><div>
<font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Incidentally, I also asked this question on StackOverflow, and updated it based on your reply</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><a href="http://stackoverflow.com/questions/4764434/r-when-using-data-table-how-do-i-get-columns-of-y-when-i-do-xy">http://stackoverflow.com/questions/4764434/r-when-using-data-table-how-do-i-get-columns-of-y-when-i-do-xy</a></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font><br><div class="gmail_quote">On Sat, Jan 22, 2011 at 4:48 PM, Matthew Dowle <span dir="ltr"><<a href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Welcome to the list.<br>
You're right, the FAQ is wrong.<br>
FR#1095 is "Turn back on 'join inherited scope'".<br>
This was a known problem in NEWS at v1.4 and still is.<br>
When the grouping code was moved from R into C in v1.4 that feature<br>
wasn't something that made it into the port.<br>
<br>
Glad you appreciate the neater syntax and yes it should be faster (the<br>
more columns in x and y the faster the speed up could be, over a merge<br>
followed by a query).<br>
<br>
I'll try and take a look soon.<br>
<br>
Matthew<br>
<div><div></div><div class="h5"><br>
<br>
On Sat, 2011-01-22 at 10:41 -0500, Prasad Chalasani wrote:<br>
> The Data-table FAQ 1.11 states:<br>
><br>
><br>
> "When you write x[y,foo*boo], data.table automatically inspects the j<br>
> expression to see which columns it uses.<br>
> It will only subset, or group, those columns only. Memory is only<br>
> created for the columns the j uses.<br>
><br>
> Let’s say foo is in x, and boo is in y (along with 20 other columns in<br>
> y).<br>
><br>
> Isn’t x[y,foo*boo] quicker to program and quicker to run than a merge<br>
> step followed by another subset step ?"<br>
><br>
><br>
> Contrary to what it says above, I get an error when I try to access a<br>
> y-column in the "j" argument of x[y,j].<br>
><br>
> See the sequence of code below.<br>
><br>
><br>
> > x <- data.table( foo = c(1,1,1,2,2,3), a = 1:6, key = 'foo')<br>
><br>
><br>
> > y <- data.table( foo = c(1,2), boo = 10:11, key = 'foo')<br>
><br>
><br>
><br>
> # the below works as expected<br>
><br>
> > x[y]<br>
><br>
> foo a<br>
><br>
> [1,] 1 1<br>
><br>
> [2,] 2 4<br>
><br>
><br>
> > with( merge(x,y), foo*boo)<br>
><br>
> [1] 10 10 10 22 22<br>
><br>
><br>
> # I want to acheive the same result as the above using the<br>
><br>
> # syntactically more compact (and faster?) code below:<br>
><br>
><br>
> > x[y, foo * boo ]<br>
><br>
> Error in eval(expr, envir, enclos) : object 'boo' not found<br>
><br>
><br>
> So is the FAQ just wrong, or am I misunderstanding something?<br>
><br>
><br>
</div></div>> _______________________________________________<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>
<br>
</blockquote></div><br></div>