[R] Weird feature when creating function lists with apply
Uffe Høgsbro Thygesen
uht at dfu.min.dk
Wed Oct 10 12:49:05 CEST 2001
Thanks, Peter and Prof. Ripley, for your helpful replies.
Referring to Prof. Ripley's reply, when I do
f3 <- function(a) substitute(function(x) a*x, list(a = a))
f <- lapply(1:4, f3)[]
then f is not a function:
Consistently, if I do
f4 <- function(a) eval(substitute(function(x) a*x, list(a = a)))
g <- lapply(1:4, f4)[]
then g is indeed a function:
I do still not understand what f is, then, except something that evaluates
to a function. My conclusion is that I need to start my head, too, and
understand this lazy evaluation.
Thanks again. Cheers,
Uffe H. Thygesen, M.Sc.&Eng., Ph.D.
Danish Institute of Fisheries Research
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help