Skip to content
Back to formatted view

Raw Message

Message-ID: <4339AFFD.9060008@jhsph.edu>
Date: 2005-09-27T20:47:57Z
From: Roger D. Peng
Subject: Dummy quesion about environment
In-Reply-To: <s339d562.082@wisemail.weizmann.ac.il>

Try 'get("x", env = environment(h))'

-roger

Ron Ophir wrote:
> Hi,
> I'm trying to understand environment object in R.
> I used the example:
>   f <- function(x) {
>          y <- 10
>          g <- function(x) x + y
>          return(g)
>      }
>      h <- f()
>      h(3)
> then i saw that f return an environment
> 
>>h
> 
> function(x) x + y
> <environment: 01B28570>
> but I coudn't access to x and y object in that environment:
> I tried 
> get("x",env=h)
> I tried
> h$y
> can I access y and x?
> how can I see an environment tree? oes search does it?
> Thanks,
> Ron
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/