[R] Building the call of an arbitrary function

From: Vincent Goulet <vincent.goulet_at_act.ulaval.ca>
Date: Sun 17 Sep 2006 - 16:36:12 GMT

Hy all,

Is there a direct way to build the complete function call of an arbitrary function?

Here's what I want to do. A function will build a function which will itself call a probability density function for some law given in argument to the first function:

> f("gamma", 1000)

will return, say,

function(x, shape, rate, scale = 1/rate)

    dgamma(x + 1000, shape, rate, scale = 1/rate)

(Notice that the arguments of the output function are those of dgamma().)

I tried all sorts of combinations of call(), formals(), args() et al. to no avail. But then, I avoided, so far, to build the whole thing as a character string. Would it be the only option?

Thanks for any help.

  Vincent Goulet, Professeur agrégé
  École d'actuariat
  Université Laval, Québec 
  Vincent.Goulet_at_act.ulaval.ca   http://vgoulet.act.ulaval.ca

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon Sep 18 02:40:28 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 17 Sep 2006 - 19:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.