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.