Skip to content

[R-pkg-devel] NAMESPACE and S4 classes

2 messages · Boylan, Ross, Uwe Ligges

#
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?

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

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?
#
On 06.11.2015 00:52, Boylan, Ross wrote:
Yes, if a user shoudl have access to the constructor.
Yes, if not only used internally by your own functions.
Right, you need to import the generics you want to use.

Best,
Uwe Ligges