[R] Loading a "sub-package"
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Wed Oct 29 10:17:22 CET 2003
On 28-Oct-03 Prof Brian Ripley wrote:
> On Tue, 28 Oct 2003 Ted.Harding at nessie.mcc.ac.uk wrote:
>
>> But MASS is huge! Hence the query. (I've also had occasion to filch
>> single functions from other libraries as well).
>
> MASS is *not* huge, and indeed is negligible compared to what is
> already loaded. nlme might be large, but few packages are noticeable
> and none are huge ....
Sorry! I didn't want to give an impression of making derogatory remarks
about MASS (or any other library), and admittedly it is a small fraction
of the size of nlme.
However, loading MASS seems to increase R's footprint in RAM by about
800KB (as reported by 'ps'), a substantial fraction of what's still
free when I'm working on my 128MB laptop, and (from another point of
view) this is indeed huge compared with the 600 bytes or so required
to define 'mvrnorm' on its own; and is a not-negligible bite out of
available RAM! (As I said before, I in fact simply pinched the code
stand-alone for this particular function, but it did prompt the
general query for cases where this might not be so straightforward).
> Luke and I (but principally Luke) have been experimenting with
> load-on-demand for R objects, and indeed MASS already does that for
> its data objects. It's possible that this will be a non-issue by
> the next non-patch release.
This will be welcome, and many thanks for the effort! Does this mean
that it would be possible to do something like
load.function(mvrnorm,package=MASS)
and get just that function (and, in the case of some functions, any
other functions they may depend on)?
> Some data (R 1.8.0 --vanilla)
>
>> gc()
> used (Mb) gc trigger (Mb)
> Ncells 416460 11.2 597831 16
> Vcells 113224 0.9 786432 6
>> library(MASS)
>> gc()
> used (Mb) gc trigger (Mb)
> Ncells 463337 12.4 667722 17.9
> Vcells 121995 1.0 786432 6.0
>
> I'd fail any student who said `MASS was huge'.
Thankfully I do not anticipate taking any more examinations ... :)
> I assume you don't have methods loaded if you are concerned about
> performance ....
An interesting question ... to which I have to answer "yes, I think
I do": for the reason it seems to be loaded by default[1] and my reading
of ?Methods has given me the impression (I don't understand R's workings
to the point where I feel I _know_ anything about this for sure) that a
lot of things one takes for granted in normal use of R would not work as
expected without it. For instance:
The R package 'methods' implements, with a few exceptions, the
programming interface for classes and methods in the book
_Programming with Data_ (John M. Chambers, Springer, 1998), in
particular sections 1.6, 2.7, 2.8, and chapters 7 and 8.
[1] At any rate, things listed by library(help=methods) are known
to R on startup.
So another interesting question in turn: What would be the effect on
general use of setting up R start-up so that "methods" was not loaded
by default? And, indeed, how might this be done? (I can't find where
the default loading of "methods" is initiated).
With thanks again,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 29-Oct-03 Time: 09:17:22
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list