[datatable-help] Weird behavior with S4 subclasses of data.table after loading RCurl
Matthew Dowle
mdowle at mdowle.plus.com
Sun Sep 30 00:21:19 CEST 2012
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
Matthew
> This is a repost from
> http://stackoverflow.com/questions/12655600/weird-behavior-with-data-table-devtools-and-s4,
> but now I'm using version 1.8.2 of data.table.
>
> I am getting some really weird behavior when trying to write an S4
> subclass
> of *data.table*. In short, after loading the *RCurl* package, the "["
> method no longer can find variable names in the scope of the data table. I
> originally found this out while developing a package with the
> *devtools* package,
> and traced the problem to importing *RCurl*. *RCurl* and *data.table* are
> up to date.
>
> At this point, I have no idea what's going on, but I think the following
> code is the best minimal example that reproduces this behavior.
>
>> 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
>
>>
>
>> 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))
>
>>
>
>> ## Everything works!
>
>>
>
>> tables()
>
> NAME NROW MB COLS KEY
>
> [1,] DT1 9 1 x,y,v
>
> [2,] DT2 9 1 x,y,v
>
> Total: 2MB
>
>> is(DT2, "data.table")
>
> [1] TRUE
>
>>
>
>> DT1[2]
>
> x y v
>
> 1: a 3 2
>
>> DT2[2]
>
> x y v
>
> 1: a 3 2
>
>>
>
>> (bracketMethods1 <- methods("["))
>
> [1] [.acf* [.AsIs [.bibentry* [.data.frame
>
> [5] [.data.table* [.Date [.difftime [.factor
>
> [9] [.formula* [.getAnywhere* [.hexmode [.ITime*
>
> [13] [.listof [.noquote [.numeric_version [.octmode
>
> [17] [.pdf_doc* [.person* [.POSIXct [.POSIXlt
>
> [21] [.raster* [.roman* [.simple.list [.terms*
>
> [25] [.ts* [.tskernel*
>
>
> Non-visible functions are asterisked
>
>>
>
>> DT1[,v]
>
> [1] 1 2 3 4 5 6 7 8 9
>
>> DT2[,v]
>
> [1] 1 2 3 4 5 6 7 8 9
>
>>
>
>> ## These are the packages loaded/imported by RCurl (and [.data.table
> works after them).
>
>> ## library("tools")
>
>> ## DT2[,v]
>
>> ## library("bitops")
>
>> ## DT2[,v]
>
>>
>
>> 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
>
>
> loaded via a namespace (and not attached):
>
> [1] tools_2.15.1
>
>>
>
>> ## 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
>
>>
>
>> ## No changes in the extract S3 methods
>
>> (bracketMethods2 <- methods("["))
>
> [1] [.acf* [.AsIs [.bibentry* [.data.frame
>
> [5] [.data.table* [.Date [.difftime [.factor
>
> [9] [.formula* [.getAnywhere* [.hexmode [.ITime*
>
> [13] [.listof [.noquote [.numeric_version [.octmode
>
> [17] [.pdf_doc* [.person* [.POSIXct [.POSIXlt
>
> [21] [.raster* [.roman* [.simple.list [.terms*
>
> [25] [.ts* [.tskernel*
>
>
> Non-visible functions are asterisked
>
>> setdiff(bracketMethods1, bracketMethods2)
>
> character(0)
>
>> setdiff(bracketMethods2, bracketMethods1)
>
> character(0)
>
>
> Jeff
>
> ---
> Jeffrey Arnold
> Department of Political Science
> University of Rochester
> http://jrnold.me
> jeffrey.arnold at gmail.com
> jeffrey.arnold at rochester.edu
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
More information about the datatable-help
mailing list