On Mon, Jan 19, 2009 at 12:40 PM, Peter Dalgaard <p.dalga...@biostat.ku.dk> wrote: > Gabor Grothendieck wrote: >> >> Note that >> >> rm(i) >> for(j in 1:4) F(j) >> >> raises an error due to scoping issues. > > Yes. This has nothing to do with lazy evaluation, and everything to do with > scoping: f is not defined in the scope of F, so does not know about its > variables (nor those in the implicit loop of lapply()). > > Notice also that in > > lapply(1:4,function(i) F(i)) > > it would be pretty weird if lapply would behave differently depending on the > name of formal arguments of the function, i.e. if > > lapply(1:4,function(meep) F(meep)) > > gave a different result. And f() depends on looking for a variable i outside > of the function.
I believe that is what I was already referring to when I referred to "scoping issues". Since "not works" was never defined in the original post its hard to know what the problem being asked is but it might have been confusion over the different uses of i. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.