Skip to content
Back to formatted view

Raw Message

Message-ID: <CA+hbrhUeb1uqNZ0McHgt90+-22B_Bz=1i-7jy_m6UeYo3zMvkQ@mail.gmail.com>
Date: 2012-08-29T23:40:43Z
From: Peter Langfelder
Subject: Extracting the name of a function (inverse of match.fun("myFun"))
In-Reply-To: <E66794E69CFDE04D9A70842786030B93317815@PA-MBX04.na.tibco.com>

On Wed, Aug 29, 2012 at 4:14 PM, William Dunlap <wdunlap at tibco.com> wrote:
> deparse(substitute(fnc)) will get you part way there.
...
> I like to let the user override what substitute might say by
> making a new argument out of it:
>> applyFunc(function(x)x*10, 1:3)
> fnc is function(x) x * 10
> [1] 10 20 30
>> applyFunc(function(x)x*10, 1:3, fncString="Times 10")
> fnc is Times 10
> [1] 10 20 30
> This makes is easier to call your function from another one - you
> can pass the fncString down through a chain of calls.

Thanks, very good suggestions. The function I am writing is of course
much more complicated than the simplistic example.

Peter