[Rd] Possible problem with S4 dispatch

From: Seth Falcon <sfalcon_at_fhcrc.org>
Date: Mon, 30 Apr 2007 21:48:56 -0700


Hi,

First a bit of disclaimer... I haven't isolated this problem into an easy to reproduce case, and I won't be surprised if the root cause is a fault in my code's use of name spaces or some such.

The error I'm seeing is one in which the desired method is not found. What worries me in terms of my expectations of how to debug the problem is that showMethods and selectMethod both find the method. Here is an example browser session:

    ## Input 1, a character vector
    Browse[1]> gN[1:3]
[1] "1005_at" "1007_s_at" "1008_f_at"
    

    ## Input 2, an object of class AtomicAnnMap (subclass of AnnMap)     Browse[1]> class(LLe)
[1] "AtomicAnnMap"

    attr(,"package")
[1] "AnnotationDbi"
    

    ## See what selectMethod has to say (it finds the method I'm expecting)     Browse[1]> selectMethod("mget", signature(x="character", envir=class(LLe)))     Method Definition:     

    function (x, envir, mode = "any", ifnotfound = list(function(x) stop(paste("value for '",

        x, "' not found", sep = ""), call. = FALSE)), inherits = FALSE)     {

        .checkNamesAreStrings(x)
        .checkNamesExist(x, names(envir))
        as.list(envir, names = x)

    }
    <environment: namespace:AnnotationDbi>     

    Signatures:

            x envir
    target "character" "AtomicAnnMap"
    defined "ANY" "AnnMap"     

    ## Call it (we get base::mget, not the generic and hence an error)     Browse[1]> mget(gN[1:3], LLe)
    Error in mget(x, envir, mode, ifnotfound, inherits) :

            second argument must be an environment     

    Browse[1]> find("mget")
[1] "package:AnnotationDbi" "package:base"

The package code I'm working with imports the package that defines the mget method (and this package does exportMethods(mget)), yet the problem seems to be that the mget generic is not found -- but I find it confusing that selectMethod works here.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 01 May 2007 - 09:33:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 May 2007 - 08:33:59 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.