Re: [Rd] checking whether the name space can be loaded with stated dependencies

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 4 Jan 2008 22:00:51 +0000 (GMT)

On Fri, 4 Jan 2008, hadley wickham wrote:

> On 1/4/08, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:
>> What it is trying is
>>
>> % env R_DEFAULT_PACKAGES=NULL R
>>
>>> loadNamespace("ggplot2")
>>
>> The test is not new, so it would seem to be a change in ggplot2 since the
>> version on CRAN. My guess is the your package is doing top-level
>> computations, which `Writing R Extensions' warns against:
>>
>> The R code files should only create R objects and not call functions
>> with side effects such as require and options.
>
> Thanks for the additional info. I've grepped for ^[^#\n ]+\( (which I
> think should find any top-level function call) and didn't find
> anything. I certainly can't think of any top level computations that
> I'm doing apart from creating R functions and objects. Is there
> anyway to get more details about what exactly I've done wrong?

As I said, that was a guess: if it is not the cause then I am in the dark. If you can send me the version doing this I can try to dig further.

> Calling traceback after loadNamespace isn't helpful.
>
>> If you must deviate from that, you need to arrange for the environment you
>> need: when loading a name space the Depends: packages are not loaded.
>
> Is this a recent change to R?

No: that wording is ancient, and the test is not recent.

> The package appears to work fine after
> installation so I presume this check is protecting me from some more
> subtle danger.

The danger is that if some other package (or a user) does ggplot2::some_function_in_ggplot2 that this will fail if the package is not attached, similarly if a package name space imports from ggplot2.

> If it's helpful, my depends line is:
> Depends: R (>= 2.6), grid, reshape (>= 0.8.0), proto, splines, MASS,
> RColorBrewer, colorspace
>
> so only proto or RColorBrewer should be a problem.
>
> Hadley
>
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 04 Jan 2008 - 22:04:19 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 Tue 08 Jan 2008 - 09:30:08 GMT.

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

list of date sections of archive