[R-pkg-devel] NAMESPACE and S4 classes

2015-11-06 Thread Boylan, Ross
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?
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] NAMESPACE and S4 classes

2015-11-06 Thread Uwe Ligges



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.

Best,
Uwe Ligges


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel