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

Thomas Lumley tlumley at u.washington.edu
Thu Apr 11 21:43:07 CEST 2002


On Thu, 11 Apr 2002, Rolf Turner 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?
>


R> f
function(...){
substitute(list(...))
}
R> f(melvin,clyde,irving)
list(melvin, clyde, irving)

If you want text strings you will have to convert them with eg
as.character, or supply text strings as the arguments

R> f("melvin","clyde","irving")
list("melvin", "clyde", "irving")

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

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