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 <[email protected]>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 > [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] RCurl_1.95-0 bitops_1.0-4.1 data.table_1.8.2 > > ## cedta is still TRUE > > data.table:::cedta() > [1] TRUE > > > > ## This still works > > DT1[,v] > [1] 1 2 3 4 5 6 7 8 9 > > ## This no longer works > > DT2[,v] > Error: object 'v' not found > > > > ## DT2 still behaving like data.table and not data.frame in other > respects > > DT2[ , 4] > [1] 4 > > DT2[ , "v"] # returns v instead of the column > [1] "v" > > DT2[ , "v", with=FALSE] # returns the column > v > 1: 1 > 2: 2 > 3: 3 > 4: 4 > 5: 5 > 6: 6 > 7: 7 > 8: 8 > 9: 9 > > > > On Sat, Sep 29, 2012 at 8:34 PM, Steve Lianoglou < > [email protected]> wrote: > >> Hi, >> >> On Sat, Sep 29, 2012 at 6:21 PM, Matthew Dowle <[email protected]> >> wrote: >> > >> > Hi, >> > >> > Quick answer to start. Assuming your package Imports or Depends on >> > data.table (in the DESCRIPTON file) then see here for description of >> > `cedta` and how it works and maybe it needs a fix : >> > >> > http://stackoverflow.com/a/10529888/403310 >> >> Quick note: this doesn't look like it has to do w/ cedta ... I was >> debugging this w/ the sample provided and cedta() returns TRUE. >> >> Somehow ~ line 780 of data.table.R, `xvars` is empty and I guess the >> column is injected into the SDenv befure the `jval = eval(jsub,SDenv)` >> call, so its not found. >> >> -steve >> >> -- >> 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 >> > >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
