[R] Variable Scope
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Apr 12 13:14:44 CEST 2006
On 4/12/2006 5:49 AM, James Kirkby wrote:
> Hi,
>
> I was wondering if there is a way to stop R looking outside the scope of
> a function, if it can't find the variable inside the function.
>
> I seem to waste hours debugging functions only to find I've used a wrong
> variable name somewhere, but the function still works because the
> variable exists higher up the hierachy. It seems it would be easier to
> debug if the function just went splat when it couldn't find the variable.
You don't want to do this, because very little in R is built-in to the
language, many things (e.g. "+", "if", etc.) are functions stored in
some environment outside your function.
Duncan Murdoch
More information about the R-help
mailing list