[R] creating a package with internal (hiden) S4 classes and methods

Marie-Pierre Sylvestre marie-pierre.sylvestre at mail.mcgill.ca
Thu Sep 11 19:52:16 CEST 2008


Dear R users,

I am writing my first R package and it finally past the R CMD check. 
Before sending it to CRAN, I would like to check a few issues.

1. I created s4 classes and methods in the package but I want only 1 
function (foo) to be available to users and documented in the manual 
that goes with the package. I put foo in 1 file and the rest (internal 
functions, classes and methods) in a file called <mypackage>-internal.R.

For the .Rd file, I created one for each class, method and internal 
functions, and I wrote  \keyword{internal} and the end.

Finally, I have created a NAMESPACE that export my function f00. I 
thought it would work but it created a problem with the classes and 
methods not being declared so I added Classes(''myclass") and 
Methods("my method") to the NAMESPACE file.

Does this make sense as to a way to <hide> classes and methods from 
users, and avoid describing them?

2. Everything goes smoothly when I R CMD build and R CMD check. However, 
when I look at the <mypackage>-manual.tex file that the R CMD check 
created, I see all my internal classes, methods and functions listed. 
This is not what I want, I only want foo.

I know that I need to send the tar.gz file to CRAN but I am clueless as 
to how the package manual (pdf) will be created. Will it look like the 
<mypackage>-manual.tex? If so, how do I make sure that only the package 
DESCRIPTION and the foo function are listed?

Please do not simply refer me to the manual 'Writing R extensions!'. I 
have read it carefully but I have to admit that some of the stuff 
explained there is beyond me. I am lost.

many thanks in advance,

MP



More information about the R-help mailing list