Suppose you want to change the default values of the arguments of
a function (to fix ideas let's use dnorm
) from mean=0,sd=1
to mean=pi,sd=pi
within the scope of another function foo
.
You could do:
T_par<-list(mean=pi,sd=pi)
x=3
do.call(dnorm,c(list(x),T_par))
but in practice I find that in my application the overhead
of using do.call
is too high.
What I would like to do is to create a function my_dnorm
that
would be a copy of dnorm
except for the default values of the
argument which would be set according T_par
and just call
my_dnorm
instead of do.call(dnorm,c(list(x),T_par))
. How to do this?