[R] scoping rules

Deepayan Sarkar deepayan at stat.wisc.edu
Mon Mar 17 06:23:29 CET 2003


On Sunday 16 March 2003 09:16 pm, Robin Hankin wrote:
> Hi
>
> I recently found a bug that was isomorphic to the following:
>
> ll1 <- 2
> increment <- function(x)
> {
>   l11 <- 1

You are not really using this variable (l11, not ll1) anywhere. Is that a 
typo? What exactly do you want to happen ?


>   return(x+ll1)   #bug here
> }
>
> Of course, R is obeying the scoping rules just fine, but I'm evidently
> not setting the do.what.I.mean.not.what.I.say variable correctly.
>
> Now, how do I avoid making this type of error? ... and what is the
> best tool for tracking it down?



More information about the R-help mailing list