[R] Getting the argument list within a function

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Sep 14 17:04:23 CEST 2004


"Roger D. Peng" <rpeng at jhsph.edu> writes:

> Is there a way of getting the argument list of a function from within
> that function?  For example, something like
> 
> f <- function(x, y = 3) {
> 	fargs <- getFunctionArgList()
> 	print(fargs)  ## Should be `alist(x, y = 3)'
> }


> f
function(x, y = 3) {
  fargs <- formals(sys.function())
  print(fargs)  ## Should be equivalent to `alist(x=, y = 3)'
}

(Notice a couple of fine points...)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list