Re: [R] more environment questions

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 29 Jul 2008 12:25:17 -0400

e1 <- ...
creates a new environment e1

environment(e1)
does nothing

print(environment(e1))
print environment e1

By the way, if you are doing a lot of manipulations of environments you might want to look at the proto package which reframes the whole thing in terms of object oriented programming.

On Tue, Jul 29, 2008 at 12:12 PM, Edna Bell <edna.bell01_at_gmail.com> wrote:
> Hi R Gurus:
>
> Here is some code that I was experimenting with, please:
>
>> f1 <- function(x) {
> + e1 <- new.env(parent=.GlobalEnv)
> + environment(e1)
> + print(environment())
> + return(mean(x))
> + }
>> f1(1:15)
> <environment: 0x02525444>
> [1] 8
>>
>
> My question: why isn't the environment within the function set to e1, please?
>
> Thanks,
> Edna Bell
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 Jul 2008 - 16:27:41 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 Tue 29 Jul 2008 - 17:32:50 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.

list of date sections of archive