Re: [R] NAMESPACE vs internal.Rd

From: Berwin A Turlach <>
Date: Thu, 17 Jul 2008 18:36:50 +0800

G'day Christophe,

On Wed, 16 Jul 2008 18:22:49 +0200 wrote:

> Thanks for your answer.

My pleasure.

> > I guess writing
> > a regular expression that says "export everything that does not
> > start with a dot but do not export foo and bar" would be not
> > trivial to write (at least not for me).
> The NAMESPACE created by package.skeleton contain a single line :
> exportPattern("^[[:alpha:]]+")
> I guess that it is what you just say...

Not really. :)

The regular expression "^[[:alpha:]]+" matches, as far as I know, all objects that have one or more alphabetic character at the beginning.

The "Writing R Extensions" manual suggests "the directive


exports all variables that do not start with a period."

As far as I can tell, both these instructions have more or less the same effect (assuming that there are no objects with non-standard names in your package; and I am not enough of an R language lawyer to know what would happen in such a case).

I was commenting on your classification as:

> - some fonction will be "accessible" (regular function)
> - some function will be "hidden" (function starting with .)
> - some function will be "forbiden" (function not in namespace)

Say, you have "accessible" functions called fubar, rabuf, main and something.incredible.useful, some hidden functions whose name start with a . and "forbidden" functions (i.e. not exported) with names foo and bar. (Though, as I commented earlier, it is practically impossible to implement "forbidden" functions, users can always access them if they want using ":::".)

Both of the directives above would export fubar, rabuf, main, something.incredible.useful, foo and bar.

So my challenge was to come up with a regular expression for exportPattern that says "export everything that does not start with a dot but do not export foo and bar", i.e. a regular expression that would only export the "accessible" functions.

HTC. Cheers,

        Berwin mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 Jul 2008 - 10:39:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jul 2008 - 12:31:58 GMT.

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

list of date sections of archive