[R] Function match.call or saving all initial parameters

From: Aleš Žiberna <ales.ziberna_at_guest.arnes.si>
Date: Fri 18 Mar 2005 - 04:39:05 EST


Hello!

I am interested, is it possible to get a call from the function (like with match.call), but in such a way that the call would include all elements to a function, not only those that were set in a call. What I want is to have also specified arguments that are not listed in the original call and for which the default values are used. I would like to know all arguments used so I could replicate the call. An example follows at the end.

I have searched the help files and the mailing list archives, but have not found a solution.

Thank you in advance for any advice!

Ales Ziberna

For example,
if I have a function:

my.fun<-function(x,n=1,...){

    call<-match.call()
    res<-list(rep(x = x, times = n),...) return(list(res=res,call=call))
}
#If I call this function
a<-2
b<-3
res<-my.fun(a,b=b)
#the call element of the result is

res$call #here I only exact the call and get
#my.fun(x = a, b = b)

However, I would like to get
my.fun(x = 2, n = 1, b = 3)

I tried usning substituting
call<-match.call()
with
inital.param<-lapply(as.list(sys.frame(sys.nframe())),eval) #to get initial parametrs, whih is esentially what I want However, this does not give me the arguments in ..., in the example argument b.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Mar 18 05:10:56 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST