[Rd] S4 coercion responsibility

Seth Falcon seth at userprimary.net
Thu Sep 18 06:21:10 CEST 2008


Continuing to talk to myself here...

* On 2008-09-17 at 21:06 -0700 Seth Falcon wrote:
> *argh* I'm certain this was working for me and yet when I try to
> reproduce in a new R shell it errors out.

This looks like an infelicity in the methods caching.

To make it work:

    library("RSQLite")
    setClass("SQLConPlus", contains=c("SQLiteConnection","integer"))
    dd = data.frame(a=1:3, b=letters[1:3])
    con.orig = dbConnect(SQLite(), ":memory:")
    con = new("SQLConPlus", con.orig, 11L)

    ## call selectMethod, must have a side-effect on the
    ## methods cache
    selectMethod(coerce, signature=c("SQLConPlus", "integer"))

    dbWriteTable(con, "t1", dd)
    dbListTables(con)
    dbDisconnect(con)

Now I get:

    as(con, "integer")
    [1] 15719     0

Haven't tried the above in an older version of R.

-- 
Seth Falcon | http://userprimary.net/user/



More information about the R-devel mailing list