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

From: Seth Falcon <sfalcon_at_fhcrc.org>
Date: Thu 08 Jun 2006 - 00:29:47 EST

"Antonio, Fabio Di Narzo" <antonio.fabio@gmail.com> writes:

> 1. If you have time to change internal functions naming, you can rename
> internal functions by putting a leading '.'.
> Even without namespace, I have noticed there is no check for corresponding
> docs for such functions.
>
> 2. If you don't want to rename all internal functions, the best way is
> writing an 'internals.Rd' file with an alias for each internal function
> (documented in 'writing R extensions').
>
> 3.Finally, you can add a NAMESPACE (see writing R extensions). However, if
> you use S3/S4 classes, this can be much more tedious to do.
>
> I think the no. 2 to be the fastest/safer way.

I think adding a NAMESPACE file is the best solution and I don't think that the process needs to be particularly tedious.

Having a naming convention for private functions is fine and you can still do that with a NAMESPACE. Non-exported functions do not get checked for documentation, so there is no need for an internals.Rd (of course, it doesn't hurt to give yourself some documentation for when you return to the project 3 months later :-)

Besides hiding your private functions, a NAMESPACE protects you from users or other packages redefining functions that you rely on. As an extreme example, if a user redefined length(), many packages without namespaces would break.

+ seth



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 08 02:20:24 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 Thu 08 Jun 2006 - 04:10:35 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.