[R] control enviromnet

facS93@hampshire.edu facS93 at hampshire.edu
Thu Oct 7 02:49:24 CEST 2004


Hi all:

I would like to implement an option in my function so that it warns me of any 
variables that are not defined in the current environment - if it needs to 
look up variables in the parent frame, it tells me so. 

The following is an example and it does what I want, and I'd rather have the 
environment control option inside this function instead of outside. Any help 
would be greatly appreciated.

x = 1
test = function(y) {
 ans = y + x;
 return(ans);
}
environment(test)=NULL
test(y = 1)

Thanks much!

Fang




More information about the R-help mailing list