From within a function, how can I extract the individual arguments that make up ...? I'm sure this has been discussed on here before but ... does not get indexed. Any suggestions as to what I should search for would be equally welcome. Thanks, Hadley
I found what I was looking for in R-lang: args <- list(...) for (a in args) Hadley
On Sun, 9 Nov 2003, Hadley Wickham wrote:> From within a function, how can I extract the individual arguments that > make up ...?dots <- list(...) names(dots) is the most common paradigm. You can also use match.call(expand=TRUE)> I'm sure this has been discussed on here before but ... does not get > indexed. Any suggestions as to what I should search for would be > equally welcome.Well, that's why there are books about S Programming ... (p.46 gives a more sophisticated version). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On 9 Nov 2003 at 10:29, Hadley Wickham wrote: Does the following help?> test <- function(...) {+ return( list(...) ) + }> test(a=4, b=7, test=17)$a [1] 4 $b [1] 7 $test [1] 17 Kjetil Halvorsen> From within a function, how can I extract the individual arguments that > make up ...? > > I'm sure this has been discussed on here before but ... does not get > indexed. Any suggestions as to what I should search for would be > equally welcome. > > Thanks, > > Hadley > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help