Skip to content
Prev 26611 / 398502 Next

Writing packages with `methods' package

The problem here is that the standard R way of attaching a package is to
source in the R code; when the code contains setMethod() calls and the
like, the result is to store the resulting definitions in the global
environment.

When you're writing packages using methods, you essentially always want
to use an alternative installation for the package, which creates a
binary image when R INSTALL runs.   This image is loaded when the
package is attached by calling library(), and the objects for methods,
etc. are in the package database,as you would like.

There's a paragraph in the online documentation for INSTALL that
describes what to do.  (if you want a quick fix, just touch an empty
file install.R in the package's top level directory.)

When you run INSTALL, you should see a line:

** save image

in the printout.  And no files generated in the global environment from
calling library()

Regards,
 John Chambers
Roger Peng wrote: