[R] Obtaining names of ``...'' arguments.

Deepayan Sarkar deepayansarkar at yahoo.com
Thu Apr 11 22:15:24 CEST 2002



foo <- function(...) as.character(match.call(expand.dots = FALSE)$"...")

should give you the names a a character vector.

--- Rolf Turner <rolf at math.unb.ca> wrote:
> This may be an FAQ, but a (perfunctory) search failed to turn it up.
> 
> Suppose I have a function foo(...){<something>} and I want to obtain,
> inside foo, the names of items comprising the ``...''.  E.g. if I
> call
> 
>  foo(melvin,clyde,irving)
>
> I want to be able to loop through the ``...'' and successively obtain
> the text strings "melvin", "clyde", and "irving".
> 
> Is there any way to do this?
> 
> I know that if I had a function foo(x,y,z){<something>}, and I called
> foo(melvin,clyde,irving), I could get the text strings I want by
> means of
> 
>  deparse(substitute(x)) # Giving "melvin".
>  deparse(substitute(y)) # Giving "clyde".
>  deparse(substitute(z)) # Giving "irving".
> 
> but if foo() is to take an arbitrary number of arguments then this
> sort of syntax is not available.
> 
>      cheers,
> 
>       Rolf Turner
>       rolf at math.unb.ca
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

__________________________________________________



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