[Rd] Loading of namespace on load of .Rdata (was strange behaviour of load)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Jan 18 14:31:08 CET 2006
On Wed, 18 Jan 2006, Heather Turner wrote:
[Lines wrapped for legibility and R-help removed as it is not an
appropriate list.]
> Last week Giovanni Parrinello posted a message asking why various
> packages were loaded when he loaded an .Rdata file. Brian Ripley replied
> saying he thought it was because the saved workspace contained a
> reference to the namespace of ipred. (Correspondence copied below).
>
> This begs the question: how did the reference to the namespace of ipred
> come to be in the .Rdata file? Brian did say it is likely to be because
> the workspace contained object(s) saved with environment the namespace
> of ipred - but how would this come about?
>
> In this case I think is because the .Rdata file contained an object
> whose *parent* environment was the namespace of ipred. Take the
> following example from ?bagging (having loaded ipred):
Excuse me: environments do not have parents but enclosures according to
?environment.
Of course, the environment of mod is itself an object, and so my statement
holds true. Saving a workspace saves all the objects (possibly as
references) whether named or not. I was fully aware that the namespace
was likely to be up the environment tree of a named object when I chose my
words carefully.
>> data(BreastCancer)
>>
>> mod <- bagging(Class ~ Cl.thickness + Cell.size
> + + Cell.shape + Marg.adhesion
> + + Epith.c.size + Bare.nuclei
> + + Bl.cromatin + Normal.nucleoli
> + + Mitoses, data=BreastCancer, coob=TRUE)
>>
>> environment(mod$mtrees[[1]]$btree$terms)
> <environment: 024E8138>
>>
>> parent.env(environment(mod$mtrees[[1]]$btree$terms))
> <environment: namespace:ipred>
parent.env is a very confusing name. To quote the draft R language
definition:
`The parent.env function may be used to access the enclosure
of an environment.'
[...]
--
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