[datatable-help] Streamlining unit tests with test_that

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue Nov 30 23:03:25 CET 2010


On Tue, Nov 30, 2010 at 3:48 PM, Tom Short <tshort.rlists at gmail.com> wrote:

> Cludgy, but this datatable-test.R works:
>
> assign(".Depends", "data.table", envir = topenv())
> TESTDT = data.table(a=as.integer(c(1,3,4,4,4,4,7)),
>                    b=as.integer(c(5,5,6,6,9,9,2)),
>                    v=1:7)
> setkey(TESTDT,a,b)
> x <- TESTDT[SJ(4,6), v, mult="first"]

Hmm ... that's not working for me:

R> sys.source("~/Desktop/datatable-test.R", new.env(parent=.GlobalEnv))
Error in `[.data.frame`(x, i, j) : object 'v' not found

I'm using R 2.12 (sessionInfo below).

I was thinking about something along the lines of your toplevel hidden
variable idea, but thought it might be a bit sloppy.

I guess the cedta stuff is necessary when the user passes a data.table
into a function (perhaps defined in a package) that expects a
data.frame?

I guess one starts to tread in some of the arcane aspects of R when
one needs to test/manipulate namespaces and things.

I wonder if there's another way to implement cedta? Would checking the
values/order of `searchpaths` from within cedta work? (Assuming the
values/order of the elements in searchpahts() changes from within
packages, etc.)

-steve

R> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] data.table_1.5.1

-- 
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


More information about the datatable-help mailing list