[R] Name the dots! ("...")

andrewH ahoerner at rprogress.org
Sat Sep 17 11:27:21 CEST 2011


Dear Folk--

Suppose I have some objects A, B & C, and a function
getDots <- function(...) {args <- list(...)  etc.}

If I do a call to getDots(A, B, C) then the variable args will be assigned
to a list which contains the objects to which A, B & C refer, but which will
not (except by happenstance) contain the names A, B, or C.  I would like
getDots to return a named list, with the object names being assigned as the
element names in the list. 

Is there any way to do this? 

As an aside, I do not understand why the list command does not do this by
default, like the data.frame command does.  In fact, you can use data.frame
instead of list to get a named argument list, but only if all your objects
are of the same length.

Thanks in advance for any help you can offer.
andrewH

--
View this message in context: http://r.789695.n4.nabble.com/Name-the-dots-tp3819947p3819947.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list