Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Duncan Murdoch
On 14/05/2010 10:14 AM, thmsfuller...@gmail.com wrote: Hello All, By default, a reference of a variable in a function cause R to look for the variable in the parent environment if it is not available in the current environment (without generating any errors or warnings). I'm wondering if there i

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Simon Urbanek
On May 14, 2010, at 11:33 AM, thmsfuller...@gmail.com wrote: > On Fri, May 14, 2010 at 10:13 AM, Simon Urbanek > wrote: >> >> On May 14, 2010, at 10:29 AM, Jeff Ryan wrote: >> >>> This isn't like a local variable though, since any function above the >>> baseenv() in the search path will also n

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread thmsfuller...@gmail.com
On Fri, May 14, 2010 at 10:13 AM, Simon Urbanek wrote: > > On May 14, 2010, at 10:29 AM, Jeff Ryan wrote: > >> This isn't like a local variable though, since any function above the >> baseenv() in the search path will also not be found. >> > > Yes, but that is a consequence of the request and henc

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Simon Urbanek
On May 14, 2010, at 10:29 AM, Jeff Ryan wrote: > This isn't like a local variable though, since any function above the > baseenv() in the search path will also not be found. > Yes, but that is a consequence of the request and hence intended. You can always either specify the full path to the f

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Hadley Wickham
On Fri, May 14, 2010 at 10:10 AM, Gabor Grothendieck wrote: > You can get around that by using this instead: > > environment(f) <- as.environment(2) > > provided it is done after you have loaded all your packages. Another approach is to inspect function by function: library(codetools) findGlobal

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Gabor Grothendieck
You can get around that by using this instead: environment(f) <- as.environment(2) provided it is done after you have loaded all your packages. On Fri, May 14, 2010 at 10:29 AM, Jeff Ryan wrote: > This isn't like a local variable though, since any function above the > baseenv() in the search pa

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Jeff Ryan
This isn't like a local variable though, since any function above the baseenv() in the search path will also not be found. > f function(a) { rnorm(b) } > f() Error in f() : could not find function "rnorm" Jeff On Fri, May 14, 2010 at 9:20 AM, Hadley Wickham wrote: > > Hello All, > > > > By d

Re: [Rd] Restrict access to variables in parent environment

2010-05-14 Thread Hadley Wickham
> Hello All, > > By default, a reference of a variable in a function cause R to look > for the variable in the parent environment if it is not available in > the current environment (without generating any errors or warnings). > I'm wondering if there is a way to revert this behaviors, such that it

[Rd] Restrict access to variables in parent environment

2010-05-14 Thread thmsfuller...@gmail.com
Hello All, By default, a reference of a variable in a function cause R to look for the variable in the parent environment if it is not available in the current environment (without generating any errors or warnings). I'm wondering if there is a way to revert this behaviors, such that it will not l