[R] Writing packages with `methods' package

Roger Peng rpeng at stat.ucla.edu
Mon Dec 30 02:31:02 CET 2002


I'm trying to write a package which uses classes/methods as defined in the
`methods' package.  I have a single .R file which defines the class and
various methods for that class.  At the top of the file I have

require(methods)

and then 

setClass("myclass", ...)
setGeneric("intersect")
setMethod("intersect", "myclass", function(x,y) ...)

I noticed that when I build the package and subsequently load it via
library(), the methods show up in the global workspace, which is not quite
what I wanted.

In general, is there any documentation on building packages with the
`methods' package (i.e. is it any different from building packages without
`methods'?) or perhaps an R-help thread I should look for?

In short, how should I setup my package so that my methods do not show up
in the global workspace?  

Thanks,

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng




More information about the R-help mailing list