From osklyar at ebi.ac.uk  Fri Feb 23 00:28:50 2007
From: osklyar at ebi.ac.uk (Oleg Sklyar)
Date: Thu, 22 Feb 2007 23:28:50 +0000
Subject: [Rd] Writing a package in which files must be sourced in a
 specific order
In-Reply-To: <f8e6ff050702221451n17d13a35oaa5e9859ccdb7834@mail.gmail.com>
References: <f8e6ff050702221451n17d13a35oaa5e9859ccdb7834@mail.gmail.com>
Message-ID: <45DE2732.9060606@ebi.ac.uk>

Put all loadings into functions and call the functions in .onLoad or 
.FirstLib, whatever you have there. I would simply advise not to put any 
  code outside of functions or class methods. In this way the order of 
loading will not matter, it will not depend on system or alphabet and 
you will also be able to save the loaded image of the package for faster 
loading.

Best
Oleg

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

-- 
Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466



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