Aleš Žiberna
2005-Mar-17 17:39 UTC
[R] Function match.call or saving all initial parameters
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.