[Rd] attributes of environments

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 05 Jul 2006 - 03:12:11 GMT


In the code below, e is an environment which we copy to f and then add attributes to e. Now f winds up with the same attributes.

In other words it seems that the attributes are a property of the environment itself and not of the variable. Thus it appears we cannot have two environment variables that correspond to the original environment but with different attributes.

I can understand if we changed a component of e then f would reflect that too but I am not sure that this is also desirable for attributes as they are not "in" the environment.

Is that desirable? Is it a bug? No other class works that way AFAIK. Comments?

> e <- new.env()
> f <- e
> attr(e, "X") <- "Y" # X is an attribute of e
> f # f gets the same attribute !!!

<environment: 0x01a577f0>
attr(,"X")
[1] "Y"
> R.version.string # Windows XP

[1] "R version 2.4.0 Under development (unstable) (2006-07-04 r38480)"



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Jul 05 13:14:30 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 05 Jul 2006 - 18:27:14 GMT.

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