From h.wickham at gmail.com  Wed Oct  3 16:49:57 2012
From: h.wickham at gmail.com (Hadley Wickham)
Date: Wed, 3 Oct 2012 09:49:57 -0500
Subject: [Rd] Creating functions programmatically
In-Reply-To: <CADwqtCMEax2uGOioVDJhWsobJaB5Tk0XT=Ympze6wLvUMsrLSQ@mail.gmail.com>
References: <CABdHhvH9Q3L16aCQPg=Tn5N+GqJTDW2vhf3=y6_DYcUOXwYvmQ@mail.gmail.com>
	<506C4B1F.3070403@gmail.com>
	<CADwqtCMEax2uGOioVDJhWsobJaB5Tk0XT=Ympze6wLvUMsrLSQ@mail.gmail.com>
Message-ID: <CABdHhvEF04Z0bzWZP-BU60ymdMpgaS68tVsEq5XFme_1-USiQA@mail.gmail.com>

On Wed, Oct 3, 2012 at 9:33 AM, Gabriel Becker <gmbecker at ucdavis.edu> 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

-- 
RStudio / Rice University
http://had.co.nz/



[Rd] Creating functions programmatically
Hadley Wickham