Wolfram Fischer
2002-Jun-20 07:09 UTC
[R] function returning all arguments of current call
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" Wolfram -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._