[R] function returning all arguments of current call

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Jun 20 10:34:39 CEST 2002


Uwe Ligges <ligges at statistik.uni-dortmund.de> writes:

> Wolfram Fischer wrote:
> > 
> > Is there a FUNCTION_RETURNING_ALL_ARGS()
> > which would enable to define functions with
> > different default values?
> > 
> > f1 <- function( x=1, y=1, ... ) paste( 'x =', x, 'y =', y )
> > f2 <- function( x=2, y=2, ... ) f2( FUN_RETURNING_ARGS() )
> > 
> > f1( 10 )
> > #       [1] "x = 10, y = 1"
> > f2( 10 )
> > #       [1] "x = 10, y = 2"
> 
> formals() should do the trick:
> 
>   f2 <- function( x=2, y=2, ... )  formals()
>   f2()

More likely WF is looking for 

f2 <- function( x=2, y=2, ... ) eval.parent(substitute(f1(x,y,...)))

-- 
   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
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list