Re: [Rd] Creating an environment with attributes in a package

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri, 16 Jul 2010 08:15:17 -0400

On Fri, Jul 16, 2010 at 8:08 AM, Jon Clayden <jon.clayden_at_gmail.com> wrote:
> Dear all,
>
> I am trying to create an environment object with additional attributes, viz.
>
> Foo <- structure(new.env(), name="Foo")
>
> Doing this in a standard session works fine: I get the environment
> with attr(,"name") set as expected. But if the same code appears
> inside a package source file, I get just the plain environment with no
> attributes set. Using a non-environment object works as I would expect
> within the package (i.e. the attributes remain).
>
> I've looked through the documentation for reasons for this, and the
> only thing I've found is the mention in the language definition that
> "assigning attributes to an environment can lead to surprises". I'm
> not sure if this is one of the surprises that the author(s) had in
> mind! Could someone tell me whether this is expected, please?
>
> All the best,
> Jon

I had documented a few problems I found in R here:

   http://r-proto.googlecode.com

and you might want to go over them. The item you mention is discussed in #1 there. This was written some time ago and there may have been relevant changes to R since then so it would be a good idea to double check everything with the current version of R.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 16 Jul 2010 - 12:20:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 16 Jul 2010 - 12:40:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive