[R-pkg-devel] NAMESPACE and S4 classes

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Nov 6 12:05:45 CET 2015

On 06.11.2015 00:52, Boylan, Ross wrote:
> I am trying to update a package from 2010 to the new standards, including adding a NAMESPACE file.   The package has S4 classes, and I'm having some trouble interpreting the manual.
> Suppose I have
> setClass("MyClass", .....)
> MyClass <- function(a, b, c) {...}  # constructor
> and various methods for the class
> Assuming I want to make the class and everything associated user-visible, I must
> exportClass(MyClass)
> Do I need to
> export(MyClass)
> so the constructor is visible?

Yes, if a user shoudl have access to the constructor.

> Do I need to
> exportMethods()
> for the methods of that class?

Yes, if not only used internally by your own functions.

> I take it that if the class uses a name from elsewhere in the system, e.g., it has a "print" method, I must import that too.  Or is it that I only need to import generics that are not in the base package?

Right, you need to import the generics you want to use.

Uwe Ligges

> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

More information about the R-package-devel mailing list