[Rd] Fwd: Understanding R's "Environment" concept
Greg.Snow at imail.org
Mon Jul 18 23:14:17 CEST 2011
Here is an attempt at the general concept without getting technical.
How many people in the world answer to the name/title "Dad"?
Yet based on context we can usually tell who someone is talking about when they use "Dad".
It is the same in programming, I may write a function which includes a variable named "length", but my function may call another function that also uses a variable named "length" which could be very different from my "length", the user that calls my function may have their own variable called "length". How is the computer to know which "length" to use when (and not replace the user's "length" with the one in the function)? By context of the functions, which context is called environments. Each function has its own environment and will create and use variables within that environment without affecting variables of the same name in other environments.
Environments can be used for other things as well, but that starts getting more technical.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r-
> project.org] On Behalf Of Nipesh Bajaj
> Sent: Monday, July 18, 2011 12:52 PM
> To: r-devel at r-project.org
> Subject: [Rd] Fwd: Understanding R's "Environment" concept
> *********Initially, I posted this topic in R-help however, folks there
> suggested me to post this in R-devel forum. Here is my
> Hi all, I am trying to understand the R's "environment" concept
> however the underlying help files look quite technical to me. Can
> experts here provide me some more intuitive ideas behind this concept
> like, why it is there, what exactly it is doing in R's architecture
> I mainly need some non-technical intuitive explanation.
> R-devel at r-project.org mailing list
More information about the R-devel