[R] How to use a string to refer a function?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Feb 11 23:39:26 CET 2010


See the FAQ for your question.  In addition make sure you read about
the "keep.source" option on the ?options page to find out the
situation in which attr(f, "source") will or will not work.

On Thu, Feb 11, 2010 at 5:26 PM, blue sky <bluesky315 at gmail.com> wrote:
>> f=function(){ print('in f')}
>> attr(f, 'source')
> [1] "function(){ print('in f')}"
>
> I have the above simple function. I can use the variable f to refer to
> the function and get the function source.
>
> Suppose that I have 'f' as a string (say I get it from ls()), could
> somebody let me know how to get the function from the name 'f'?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list