[R] Rcmd check does not recognize formal generic function as code object

Gordon Smyth smyth at wehi.edu.au
Wed Feb 19 05:45:03 CET 2003

Dear all,

I am trying to write a package using formal methods and classes from the 
methods package. I have not been able to get the package to pass rcmd check 
without warnings, because rcmd check does not recognize my generic 
functions as code objects and therefore queries why they have documentation 

I have isolated the problem in a very small trivial example which I give 
below. I have one file test.R in the R directory and one file test.Rd in 
the man directory. Here is the message from rcmd check:

    * checking for code/documentation mismatches ... WARNING
    Objects with usage in documentation object 'myGenericFun' but missing 
from code:
    [1] "myGenericFun"

Can I get rcmd check to recognize that myGenericFun is something that need 
a documentation entry?

The document "Writing R Extensions" doesn't cover formal methods and 
classes, and I haven't found any other documentation that covers writing 
packages using formal methods. I am working from looking at code in 
Bioconductor, pixmap and gpclib. I downloaded source for pixmap and 
confirmed that it has the same problem with rcmd check that I mention here.

Any advice gratefully received, including any tips about how to write 
organise .Rd files for generic methods.


-------------------------------- test.R -----------------------------
.initClassesandMethods <- function(where) {
         def=function(object) standardGeneric("myGenericFun"))
         def=function(object) paste("myGenericFun on object of 
         def=function(object) "myGenericFun for matrices")
#  Use of .First.lib ensures that the new generic function is assigned in 
the package itself
.First.lib <- function(libname, pkgname) {
         require(methods, quietly=TRUE)
#  Find what position in the search path this package is
         where <- match(paste("package:", pkgname, sep=""), search())
------------------------- end test.R ----------------------------------

------------------------- myGenericFun.Rd ------------------------
\title{My Generic Function}
\description{A simple example generic function.}


   \item{object}{Any R object. A special method exists for objects of class 

\value{A character string explaining the class of object and the method 

x <- rnorm(10)
dim(x) <- c(5,2)

-------------------------------- end myGenericFun.Rd -------------------
Dr Gordon K Smyth, Senior Research Scientist, Bioinformatics,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3050, Australia
Tel: (03) 9345 2326, Fax (03) 9347 0852,
Email: smyth at wehi.edu.au, www: http://www.statsci.org

More information about the R-help mailing list