3 ms·
The lambda thing may be useful. Sometimes I was tempted to do something like this > f <- function(expr) eval(substitute( function(x) expr )) > sapply(1:
by kgwgk 6y ago
The lambda thing may be useful. Sometimes I was tempted to do something like this
> f <- function(expr) eval(substitute( function(x) expr ))
> sapply(1:4, f({ a <- x^2 ; b <- x^3 ; a+b }))
[1] 2 12 36 80
but I'm not sure it would have worked well. The new syntax is of course also more flexible.
- iaw 6y agoI've literally written something similar 4 times in the last month, I hate having to load the temp function to be sure the next line runs. This is such a useful addition.