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

From: Greg Snow <>
Date: Mon, 18 Jul 2011 15:14:17 -0600

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

> -----Original Message-----
> From: [mailto:r-devel-bounces_at_r-
>] On Behalf Of Nipesh Bajaj
> Sent: Monday, July 18, 2011 12:52 PM
> To:
> 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,
> ______________________________________________
> mailing list
______________________________________________ mailing list
Received on Mon 18 Jul 2011 - 21:16:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Mon 18 Jul 2011 - 22:20:10 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive