How do I show the source code of an S4 function in a package?

前端 未结 3 1624
小鲜肉
小鲜肉 2020-12-08 02:35

I used the packages topGO in R to analyze gene enrichment with the following code:

sampleGOdata <- new(\"topGOdata\", description = \"Simple session\",          


        
相关标签:
3条回答
  • 2020-12-08 03:13

    I know this is an old question, but for the sake of completeness for future searchers, there's also a function called

    selectMethod
    

    that varies from getMethod in that you can use inheritance. This is how I found source for a generic function that has multiple signatures.

    0 讨论(0)
  • 2020-12-08 03:20

    Note that as of R version 2.11.0, one needs to use findMehtods(). Here is an extract from the changelog.

    getMethods() is now deprecated, with its internal use replaced by findMethods() and other changes. Creating objects from the "MethodsList" class is also deprecated.

    0 讨论(0)
  • 2020-12-08 03:32

    Use getMethod() and specify the signature. In your case, that could be eg :

    getMethod("GenTable","topGOdata")
    

    to show the GenTable method for topGOdata objects. In this case, there is only a method defined for topGOdata objects. In case there are methods with different signatures, showMethods() will tell you which ones. In your case :

    showMethods("GenTable")
    # Function: GenTable (package topGO)
    # object="topGOdata"
    

    You can get the code for the signature you want by specifying it in the getMethod() function.

    0 讨论(0)
提交回复
热议问题