[R] lazy loading like object
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue May 28 11:07:19 CEST 2013
1) This is a topic for the R-devel list.
2) It sounds like something which should be done at installation, and
can easily be done via top-level code in your R files.
3) We have no idea what 'gdal-bin' is, nor how that can be a 'library'.
But save()-d R objects are portable unless something like external
pointers are involved (when they cannot be saved properly).
On 28/05/2013 08:20, Matteo Mattiuzzi wrote:
> Dear List,
> I'm writing the package MODIS (currently on R-forge), I lazy load some data which is a very elegant solution. These lazy loaded objects are typically used inside functions, most of that objects are not directly used by users. One of the objects I want to lazy load (is a result of a function) has the problem that it can only be generated having an external library (gdal-bin) installed. This installation enables _some_ (important) functionality in the package.
> The problem is that to generate this object it takes some time (on Linux less than 2 sec on windows 5 and more). I can not provide this object within the package source code (ie as RData) as I'm not sure if it is the same on every Hardware/Software environment.
> I think there are several imaginable solutions (that I can't solve by my own).
> One is to hide it for the R CMD check and INSTALL process? (This would be a solution as the object is only needed inside functions already enabled by gdal-bin)
> To generate the object and send it to the package environment...(I don't know how)
> Basically I'm aiming at a object loaded _once_after_the_check_of_the_availability_ of the external library gdal-bin. So it takes only _once_ the time to produce that object that is from now on available for any other function in the package environment.
> I hope I was clear, thanks in advanced,
> Matteo Mattiuzzi
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-help