Hi Steve, <div><br>For some reason I didn't think to look at the tests; I did take a browse at AllS4.R to see what was being defined. At least from my perspective, there isn't anything you have to do. At this point, I know what the problem is and how to work around it.  There shouldn't be problems when data.table objects are used as slots for S4 classes, because R will know it is an S3 object and only look at x when dispatching [. </div>
<div><br></div><div>But it really appears to me that as data.table is written, there is no way for S4 classes directly extending data.table to use [ with the exact same syntax. As far as I can tell (and I could be wrong), as long as data.table allows for unquoted expressions in i and j, the S4 method [ will never be able to work. But there is too much code that relies on that syntax for data.table to change it, so there really isn't much that can be done.  The next best thing is adding the S4 definitions for [ methods that at least allow the use of quoted expressions, and then warn people about in the FAQ. </div>
<div><br></div><div>I think the following method definitions will catch any case with quoted expressions in i or j and make sure they get handled correctly. I can send a true patch and write some test cases if you want. </div>
<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="courier new, monospace">setMethod("[", c(x="data.table", i="language", j="missing"),</font></div>
</div><div><div><font face="courier new, monospace">          function(x, i, j, ...) data.table(x)[i=eval(i), ...])</font></div></div><div><font face="courier new, monospace"><br></font></div><div><div><font face="courier new, monospace">setMethod("[", c(x="data.table", i="missing", j="language"),</font></div>
</div><div><div><font face="courier new, monospace">          function(x, i, j, ...) data.table(x)[j=eval(j), ...])</font></div></div><div><font face="courier new, monospace"><br></font></div><div><div><font face="courier new, monospace">setMethod("[", c(x="data.table", i="language", j="language"),</font></div>
</div><div><div><font face="courier new, monospace">          function(x, i, j, ...) data.table(x)[i=eval(i), j=eval(j), ...])</font></div></div><div><br></div></blockquote><div>Jeff</div><div><br><div class="gmail_quote">
On Mon, Oct 1, 2012 at 2:26 PM, Steve Lianoglou <span dir="ltr"><<a href="mailto:mailinglist.honeypot@gmail.com" target="_blank">mailinglist.honeypot@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jeffrey,<br>
<div><br>
On Mon, Oct 1, 2012 at 1:39 PM, Jeffrey Arnold <<a href="mailto:jeffrey.arnold@gmail.com" target="_blank">jeffrey.arnold@gmail.com</a>> wrote:<br>
> (Sorry, Steve; I realized that I originally replied to you instead of the<br>
> list)<br>
</div>[snip]<br>
<div>> I hadn't realized that I was doing something unintended when I started, or<br>
> maybe I wouldn't have :-)<br>
<br>
</div>Actually, it wasn't so unintended after all -- I had written a trivial<br>
test (inst/tests/test-S4.R) to see that we could inherit (contains)<br>
from data.table, but I never kicked the tires with "[" and stuff, so<br>
...<br>
<div><br>
>  Now R supports S4 classes inheriting from S3<br>
> classes pretty well, so it seemed like a good idea at the time.   The S4<br>
> class I am actually writing is for storing / manipulating MCMC samples. One<br>
> way to do that is to have a data.frame like object with specific columns,<br>
> e.g. "chain", "iteration", "parameter", ..., and then add functions that<br>
> take advantage of this known structure.  I want to inherit from the<br>
> data.frame directly so that it can make use of all the generic functions<br>
> defined for the data.frame.  It is more intuitive to use object[...] rather<br>
> than object@someSlotName[...].That all works great, except that these get<br>
> samples can get pretty big, so, of course, I want the performance of<br>
> data.table :-) if I can have it.<br>
<br>
</div>I agree that it would be handy to do what you want this way ... I am<br>
unfortunately a bit short on time to help you dig into this at the<br>
moment.<br>
<br>
I think the "[" methods you are defining for data.table are on the<br>
right track -- perhaps it will be a good idea to include these into<br>
the data.table package and export them. Still, one package<br>
simultaneously (and fully) supporting s3 and s4 might be a bit ...<br>
something.<br>
<span><font color="#888888"><br>
-steve<br>
</font></span><div><div><br>
--<br>
Steve Lianoglou<br>
Graduate Student: Computational Systems Biology<br>
 | Memorial Sloan-Kettering Cancer Center<br>
 | Weill Medical College of Cornell University<br>
Contact Info: <a href="http://cbio.mskcc.org/~lianos/contact" target="_blank">http://cbio.mskcc.org/~lianos/contact</a><br>
</div></div></blockquote></div><br></div>