Howdy,<div><br></div><div>The even stranger thing is that DT2[,v] never actually works for me ... with or without RCurl having been loaded.</div><div><br></div><div>I'm not sure your dispatching hunch is going to be it, though, because in my case [.data.table is always being called, but by all means please check it out.</div>
<div><br></div><div>My initial hunch would have been that you would have to `setMethod("[", "DataTable2", ...) but I guess not.</div><div><br></div><div>I'm not sure I've come across similar attempts tho, where an S4 inherits from an S3, have you? it might be helpful to see how that was wired up ...  I'm semi-surprised that this works at all :-) I think I only ever expected people to use a data.table object as a slot for another S4 object, not as its parent.</div>
<div><br></div><div>Interesting, though. Let's see ...</div><div><br></div><div>-steve<span></span><br><br>On Saturday, September 29, 2012, Jeffrey Arnold  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And what's even more unusual is that for the line<font face="courier new, monospace"> DT2[ , v]</font>,  the function<font face="courier new, monospace">`[.data.table`</font> is never called.  I included <font face="courier new, monospace">debug(data.table:::`[.data.table`)</font> and nothing happened for<font face="courier new, monospace"> DT2[ , v]</font>, but it was activated for<font face="courier new, monospace"> DT2[ , 2]</font> and the other evaluations of extract on DT2.  My hunch is that the since the S4 method is dispatching the method with a signature that includes the classes for <font face="courier new, monospace">i</font> and<font face="courier new, monospace"> j</font>, something is going wrong there since it is only getting awry when the class of<font face="courier new, monospace"> j</font> is a name.  I'm going to test out that hunch.  <div>

<div><br></div><div><div>On Sat, Sep 29, 2012 at 9:40 PM, Jeffrey Arnold <span dir="ltr"><<a>jeffrey.arnold@gmail.com</a>></span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
While I came across this while working on a package that used S4, the code in the OP has those errors when run in the global environment.  In the output below, I put data.table:::cedta() before and after loading RCurl, and it returns TRUE in both cases. The data.table object DT1 works fine before and after loading RCurl; DT2, object of the S4 class inheriting from data.table, is acting like a data.table object and not like a data.frame in all respects that I've looked at, except when I use an unquoted variable name in i. That works fine before loading RCurl, but fails after it. I have no idea what RCurl could be changing that would affect this, which is why I am stumped.<div>



<br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font face="courier new, monospace">> library("data.table")</font></div></div><div><div><font face="courier new, monospace">data.table 1.8.2  For help type: help("data.table")</font></div>



</div><div><div><font face="courier new, monospace">> sessionInfo()</font></div></div><div><div><font face="courier new, monospace">R version 2.15.1 (2012-06-22)</font></div></div><div><div><font face="courier new, monospace">Platform: x86_64-unknown-linux-gnu (64-bit)</font></div>



</div><div><div><font face="courier new, monospace"><br></font></div></div><div><div><font face="courier new, monospace">locale:</font></div></div><div><div><font face="courier new, monospace"> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              </font></div>



</div><div><div><font face="courier new, monospace"> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    </font></div></div><div><div><font face="courier new, monospace"> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   </font></div>



</div><div><div><font face="courier new, monospace"> [7] LC_PAPER=C                 LC_NAME=C                 </font></div></div><div><div><font face="courier new, monospace"> [9] LC_ADDRESS=C               LC_TELEPHONE=C            </font></div>



</div><div><div><font face="courier new, monospace">[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       </font></div></div><div><div><font face="courier new, monospace"><br></font></div></div><div><div><font face="courier new, monospace">attached base packages:</font></div>



</div><div><div><font face="courier new, monospace">[1] stats     graphics  grDevices utils     datasets  methods   base     </font></div></div><div><div><font face="courier new, monospace"><br></font></div></div><div><div>



<font face="courier new, monospace">other attached packages:</font></div></div><div><div><font face="courier new, monospace">[1] data.table_1.8.2</font></div></div></div><div><div><font face="courier new, monospace">> ## cedta is TRUE</font></div>



</div><div><div><font face="courier new, monospace">> data.table:::cedta()</font></div></div><div><div><font face="courier new, monospace">[1] TRUE</font></div></div><div><div><div><font face="courier new, monospace">> </font></div>



</div><div><div><font face="courier new, monospace">> setClass("DataTable2", contains="data.table")</font></div></div><div><div><font face="courier new, monospace">> </font></div></div><div><div>



<font face="courier new, monospace">> DT1 <- data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)</font></div></div><div><div><font face="courier new, monospace">> DT2 <- new("DataTable2", data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9))</font></div>



</div><div><div><font face="courier new, monospace">> </font></div></div></div><div><div><div><font face="courier new, monospace">> library("RCurl")</font></div></div><div><div><font face="courier new, monospace">Loading required package: bitops</font></div>



</div><div><div><font face="courier new, monospace">> sessionInfo()</font></div></div><div><div><font face="courier new, monospace">R version 2.15.1 (2012-06-22)</font></div></div><div><div><font face="courier new, monospace">Platform: x86_64-unknown-linux-gnu (64-bit)</font></div>



</div><div><div><font face="courier new, monospace"><br></font></div></div><div><div><font face="courier new, monospace">locale:</font></div></div><div><div><font face="courier new, monospace"> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              </font></div>



</div><div><div><font face="courier new, monospace"> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    </font></div></div><div><div><font face="courier new, monospace"> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   </font></div>



</div><div><div><font face="courier new, monospace"></font></div></div></div></blockquote></blockquote></div></div></div></blockquote></div><br><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">http://cbio.mskcc.org/~lianos/contact</a><br>