tags:

views:

60

answers:

2

Possible Duplicate:
Limiting variable scope

Is there a way to force R to ignore all objects set in the global environment? For example, let's say I have 'df' as an object outside of my function and I wish to use the same shorthand within my function, but not in reference to the object in the global environment

+1  A: 

See this question: "Limiting variable scope".

Shane
+2  A: 

So what? The df in your function won't be the global df.

> df = 1
> foo = function(x){df=x*2;return(df)}

Now when you do foo(df) the df inside the function isn't the global df. So what's your problem? I guess it can only be a problem if you want the global df inside your function as well, in which case:

  • don't use globals in functions - it breaks the functional style
  • use a different name if it's a different thing.
Spacedman