Skip to content

Getting names of objects passed with "..."

1 message · Gabor Grothendieck

#
See:
http://tolstoy.newcastle.edu.au/R/e2/help/06/10/2242.html
which we can modify slightly for the case in question like this:

f <- function(...) {
	x <- list(...)
	if (is.null(names(x))) names(x) <- ""
	names(x)[names(x) == ""] <- NA
	mc <- match.call()[-1]
	ifelse(is.na(names(x)), as.character(mc), names(x))
}
f(a = mean) # a
f(F = function(x)x) # F
f(a = mean, b = sd) # c("a", "b")
f(cos, sin) # c("cos", "sin")
f(a = cos, sin) # c("a", "sin")
On 6/1/07, Mike Meredith <mmeredith at wcs.org> wrote: