[Rd] R CMD check does not remove all S4 methods defined in examples
    Martin Morgan 
    mtmorgan at fhcrc.org
       
    Tue May 16 01:40:49 CEST 2006
    
    
  
Methods for generics created in '\example{}' sections of Rd files are
not entirely removed at the end of the example. This is because the
methods package caches these (in the environment returned by
getGeneric("initialize"), for the example below) as well as storing
their definition in the global environment.
The following would be derived from example code in pkg/man/eg1.Rd and
pkg/man/eg2.Rd. 'initialize' created for the first example persists in
the second, leading eventually (during R CMD check) to
> a <- new("A")
Shouldn't be here
Error in initialize(value, ...) : initialize method returned an object of class "NULL" instead of the required class "A"
[standard code and comments from pkg-Ex.R removed]
### * eg1
flush(stderr()); flush(stdout())
setClass("A", representation(x="numeric"))
setMethod("initialize", "A",
          function(.Object, ...) cat("Shouldn't be here\n"))
cleanEx(); ..nameEx <- "eg2"
### * eg2
flush(stderr()); flush(stdout())
setClass("A", representation(x="numeric"))
a <- new("A")
    
    
More information about the R-devel
mailing list