From Greg.Snow at imail.org  Mon Jul 18 23:14:17 2011
From: Greg.Snow at imail.org (Greg Snow)
Date: Mon, 18 Jul 2011 15:14:17 -0600
Subject: [Rd] Fwd: Understanding R's "Environment" concept
In-Reply-To: <CA+A3Hr5F7BG-DpwfcptauzejJ2_m3i9SgWCCn=HMTO7eXPyQqA@mail.gmail.com>
References: <CA+A3Hr6MrAOxNk3L9DZp_CQ-323J6g1efs0q+Apgk6U2OEDmJw@mail.gmail.com>
	<CA+A3Hr5F7BG-DpwfcptauzejJ2_m3i9SgWCCn=HMTO7eXPyQqA@mail.gmail.com>
Message-ID: <B37C0A15B8FB3C468B5BC7EBC7DA14CC6349CC6747@LP-EXMBVS10.CO.IHC.COM>

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
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----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
> problem*********
> 
> 
> 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
> etc.?
> 
> I mainly need some non-technical intuitive explanation.
> 
> Thanks,
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Fwd: Understanding R's "Environment" concept
Greg Snow