[R-SIG-Mac] Help request w/ function argument names

Carl Witthoft carl at witthoft.com
Thu May 15 00:14:30 CEST 2008


Hi,
I've been trying to figure out if there's a way to return the actual 
names of the arguments passed to a function which uses ellipsis.

There's an example in Vincent Zoonekynd's <zoonek at math.jussieu.fr> 
manual that looks like this:

f <- function (...)
{
l <- list(...) # Put the arguments in a (named) list
for (i in seq(along=l))
{
cat("Argument name:", names(l)[i], "Value:", l[[i]], "
\n")
}
}


I don't know exactly what he thought would happen (or what happens from 
the command line?) but from the Mac Aqua GUI, names(l) evaluates to 
NULL, or possibly the 'names' attribute of the first element of the 
first argument passed to the function, if such exists.   And in fact 'l' 
  contains the values of all elements of the arguments to f.

So, is there any way to have the function 'f'  "know" what the names are 
of the arguments passed to it?  That is, if I type


 > f(foo,bar)

I would like to be able to have the strings 'foo' and 'bar' available 
somehow.

Any advice or comments greatly appreciated.

Carl



More information about the R-SIG-Mac mailing list