On Friday 08 April 2005 09:50, Vivek Rao wrote:> Is there a way to exclude from the namespace all
> variables other than function arguments and local
> variables? For example, I would like the following
> code
>
> a = 2.0
> mult <- function(x)
> {
> pi = 3.14
> return(pi*a*x)
> }
> print(mult(10.0))
>
> to say "a not found" rather than using a = 2.0 inside
> function mult. Thanks.
Depending on why you want to do this, it might be enough to say
environment(mult) <- new.env(parent = NULL)
HTH,
Deepayan