[R] lazy loading like object
matteo.mattiuzzi at boku.ac.at
Tue May 28 14:49:33 CEST 2013
Dear Prof Ripley, thanks for your answer,
>>> Prof Brian Ripley <ripley at stats.ox.ac.uk> 05/28/13 11:07 AM >>>
1) This is a topic for the R-devel list.
Ok so I will post it to that list (if save() does not properly work).
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).
Yes sorry. gdal-bin are command-line utilities (or at least the part I want to use from are command-line utilities), I mentioned it because I wanted to point the fact of having an external program (OS-specific and maybe already installed or not), not so because of the specific program itself. My choice of words was (and probably still is) not precise.
An idea could indeed be to simply save() the object (a matrix) created once during the configuration process of 'MODIS' and the external 'gdal-bin' (done by the user after the first time 'MODIS' is loaded), and after that the object is load()-ed on every need. That should be fairly fast as the object itself is very small and it is not needed to often.
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