Apologies - I was not trying to correct you Brian, but to explore how the 
situation could arise. I'm sure you had a good idea why the namespace (or a 
reference to it) had been saved, but this was not clear to me and I thought, 
possibly not to others either.

Thanks for putting me right over parent environments vs. enclosures - again I 
was not trying to correct you with the point I made there, but to trace back 
where the reference to the namespace might have come from in Giovanni's case.

I think the issues raised are still of interest...

Heather


>>> Prof Brian Ripley <[EMAIL PROTECTED]> 01/18/06 01:31pm >>>
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,                  [EMAIL PROTECTED] 
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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to