[Rd] Writing a package in which files must be sourced in a specific order

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 23 00:46:33 CET 2007


What 'alphabetical order' is depends on the locale.  In en_NZ g < G, in C
G < g.  So it is a rather slippery concept (and gets worse in non-English 
locales: 'aa' sorts after z in Danish).

You don't tell us quite what you are doing, but R CMD INSTALL is 
working in C when concatenating the files in the R directory to ensure 
consistency across R installations.

My guess is that you need to give a collation order in the DESCRIPTION 
file (see 'Writing R Extensions'), if I am interpolating your 
comments correctly.

On Thu, 22 Feb 2007, hadley wickham wrote:

> Dear all,
>
> I have been using the proto package to create objects with mutable
> state for my ggplot package.  This has been very successful so far,
> but I have run into a problem when building/installing the package,
> because the source files need to be loaded in a specific order so that
> dependencies are initialised correctly.

'loaded'?  Do you mean sourced during INSTALL?

> I have named the files so that dependencies are loaded before they are
> needed, so that
>
> lapply(dir("~/documents/ggplot/ggplot/R", full.name=T), source)
>
> runs without error, but when installing the package I get an error
> than indicates that the files aren't being loaded in alphabetical
> order:
>
> Error in proto(Geom, { : object "Geom" not found
> Error: unable to load R code in package 'ggplot'
> Error: package/namespace load failed for 'ggplot'
>
> Can anyone suggest how I could get around this?
>
> Regards,
>
> Hadley
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
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



More information about the R-devel mailing list