[datatable-help] Weird behavior with S4 subclasses of data.table after loading RCurl

Steve Lianoglou mailinglist.honeypot at gmail.com
Sun Sep 30 10:09:50 CEST 2012


Howdy,

The even stranger thing is that DT2[,v] never actually works for me ...
with or without RCurl having been loaded.

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.

My initial hunch would have been that you would have to `setMethod("[",
"DataTable2", ...) but I guess not.

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.

Interesting, though. Let's see ...

-steve

On Saturday, September 29, 2012, Jeffrey Arnold wrote:

> And what's even more unusual is that for the line DT2[ , v],  the function
> `[.data.table` is never called.  I included
> debug(data.table:::`[.data.table`) and nothing happened for DT2[ , v],
> but it was activated for DT2[ , 2] 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 i and j, something is
> going wrong there since it is only getting awry when the class of j is a
> name.  I'm going to test out that hunch.
>
> On Sat, Sep 29, 2012 at 9:40 PM, Jeffrey Arnold <jeffrey.arnold at gmail.com>wrote:
>
> 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.
>
> > library("data.table")
> data.table 1.8.2  For help type: help("data.table")
> > sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=C                 LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] data.table_1.8.2
> > ## cedta is TRUE
> > data.table:::cedta()
> [1] TRUE
> >
> > setClass("DataTable2", contains="data.table")
> >
> > DT1 <- data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
> > DT2 <- new("DataTable2", data.table(x=rep(c("a","b","c"),each=3),
> y=c(1,3,6), v=1:9))
> >
> > library("RCurl")
> Loading required package: bitops
> > sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
>
>

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120930/e3ff2fc1/attachment.html>


More information about the datatable-help mailing list