[R] function returning all arguments of current call

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jun 20 10:11:12 CEST 2002



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()

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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