[R] from function to its name?

Seth Falcon sfalcon at fhcrc.org
Fri Mar 2 18:18:13 CET 2007


"Ido M. Tamir" <tamir at imp.univie.ac.at> writes:
> I wanted to pass a vector of functions as an argument to a function to do some 
> calculations and put the results in a list where each list entry has 
> the "name" of the function.
> I thought I could either pass a vector of function names as character, then
> retrieve the functions etc...
> Or do the opposite, pass the functions and then retrieve the names, but
> this seems not to be possible it occurred to me, hence my question.

Functions don't have to have names, by which I mean that the
definition doesn't have to be bound to a symbol.  If your function
takes a list of functions then:

  yourFunc(theFuncs=list(function(x) x + 1))

You could force the list to have names and use them.  Or you could
force function names to be passed in (your other idea).

+ seth



More information about the R-help mailing list