[R] setClass() and packages

Douglas Bates bates at stat.wisc.edu
Tue May 21 18:37:33 CEST 2002


We use file names like

 AllClass.R   # definition of classes
 AllGeneric.R # definition of generic functions

(or perhaps AllClasses.R and AllGenerics.R for the fastidious).  As
you say, these are not guaranteed to be processed first but we tend to
use lower case letters for our other .R file names.

By the way, I notice that Robert Gentleman used wrappers like

if (!isGeneric("logDet")) {
    setGeneric("logDet",
               function(object)
               standardGeneric("logDet"), "numeric")
}

in one of his packages in Bioconductor so as to avoid accidently
redefining generics.  I think that is a good idea.


"Henrik Bengtsson" <hb at maths.lth.se> writes:

> Where should the setClass() ('methods' package) calls be placed in a
> package? I try to follow a one-class-one-file principe, but since
> setClass("ClassA", "ClassB") has to come a after setClass("ClassB", [snip])
> it is not possible to fully follow this rule. So the best I can do now is to
> put all setClass() calls in a file named "000.R" (I know this file is *not*
> guaranteed to be included first, but it works with current build script):
> 
>   setClass("ClassB", [snip])
>   setClass("ClassA", "ClassB")
>   ...
> 
> Doing like this is fine with me, but is this the correct/best way? How are
> other people dealing with this "problem"?
> 
> [R v 1.5.0 2002-04-29 on WinMe]
> 
> Thanks
> 
> Henrik Bengtsson
> 
> Dept. of Mathematical Statistics @ Centre for Mathematical Sciences
> Lund Institute of Technology/Lund University, Sweden (+2h UTC)
> Office: P316, +46 46 222 9611 (phone), +46 46 222 4623 (fax)
> h b @ m a t h s . l t h . s e, http://www.maths.lth.se/bioinformatics/
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-- 
Douglas Bates                            bates at stat.wisc.edu
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list