On Oct 3, 2012, at 16:49 , Hadley Wickham wrote:

> On Wed, Oct 3, 2012 at 9:33 AM, Gabriel Becker <[email protected]> wrote:
>> Hadley,
>> 
>> You could do this:
>> 
>> make_fun = function(args, body, env)
>> {
>> f = function()
>> formals(f) = args
>> body(f) = body
>> environment(f) = env
>> f
>> }
>> 
>> If for some reason using function() itself as Duncan suggested won't work.
> 
> Oh that's an approach that's easier to explain to others - thanks!
> 
> Hadley

There's also as.function(), although its semantics are a bit arcane. It and the 
converse as.list.function() have their origin in S-PLUS, where it was 
commonplace (or relatively so) to treat a function as a list, like in ls[[2]].

> 
> -- 
> RStudio / Rice University
> http://had.co.nz/
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [email protected]  Priv: [email protected]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to