Note that rm(i) for(j in 1:4) F(j)
raises an error due to scoping issues. On Sun, Jan 18, 2009 at 10:02 PM, <markle...@verizon.net> wrote: > I've been going back to old difficult R-list "evaluation" emails that I save > in order to understand evaluation better and below still confuses me. Could > someone explain why A) works and B) doesn't. A variant of below is in the > Pat's Inferno book also but I'm still not clear on what is happening. > Thanks. > > f <- function() { > # FORCING i here doesn't help > i*i > } > > F <- function(i) { > force(i) > print(f()) > } > > A) THIS WORKS > for ( i in 1:4 ) { > F(i) > } > > B) THIS DOESN'T > lapply(1:4,function(i) F(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. > ______________________________________________ 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.