Re: [R] Building packages in R - 'private' functions

From: Joerg van den Hoff <>
Date: Wed 07 Jun 2006 - 17:49:54 EST

Dan Rabosky wrote:
> Hello.
> I am creating an R package that I'd like to submit to CRAN (OS Windows
> XP). How do I distinguish among 'public' functions, e.g., those that are
> intended to be called by users of the package and for which I am providing
> documentation & examples, and 'private' functions, which are used
> internally by the 'public' functions, but for which I do not wish to
> provide documentation? The private functions are all coded in R (nothing
> in C or Fortran) and are essential to the operation of several public
> functions.
> I have been unable to find any documentation on this in the 'writing r
> extensions' manual', on previous posts to R-help, or through any other
> source. One possibility is to include the source code for the 'private'
> functions within the public functions. However, since multiple public
> functions utilize the same core set of 'private' functions, this seems
> unwieldy and redundant at best.
> If I simply include the source for the 'private' functions in the "R"
> directory (without corresponding *.Rd and *.html documentation in /man),
> then check the package with "R CMD check', it does appear to process the
> private functions (and successfully builds with R CMD build). However, I
> do receive a warning for including undocumented code objects. Is this the
> recommended approach and/or is there a better way to do this? One
> potential problem with this approach is that - should an error occur within
> a private function, it may be very difficult for the user to decipher the
> nature of the problem.
> Any suggestions will be greatly appreciated.
> ~Dan Rabosky
> Dan Rabosky
> Department of Ecology and Evolutionary Biology
> 237 Corson Hall
> Cornell University
> Ithaca, NY14853-2701 USA
> web:
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!

it's in the 'extensions' manual, including an example I believe:

create a file `NAMESPACE' in the package top level dir (beside `R' and `man') containing the single line


name all private functions with a leading `.' (more precisely: all functions starting with a `.' are private in this setting).

of course, you can modify the pattern to suit another naming convention.

joerg mailing list PLEASE do read the posting guide! Received on Wed Jun 07 18:01:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 07 Jun 2006 - 20:10:31 EST.

Mailing list information is available at Please read the posting guide before posting to the list.