[R] dot-dot-dot as an actual argument

Jyotirmoy Bhattacharya jmoy.matecon at gmail.com
Fri Feb 19 12:25:04 CET 2010


I could not find any documentation of how dot-dot-dot works when used
as an argument in a function call (rather than as a formal argument in
a definition). I would appreciate some references to the rules
governing situations like:

f1<-function(x,y,...){
  print(x)
}

f2<-function(...){
  f1(...)
}

f2(1,2,3)

In the call above how are the three numbers bound to the individual
formal arguments x and y of f1 rather than f1 being called with a
single pairlist, which is what the documentation says ... is.

And while the example above succeeds, why does the following fail,

library(lattice)
f.barchart <- function(...) {
    barchart(...)
}

x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1))
print(f.barchart(a ~ b, data = x, groups = d))

This gives the error:
Error in eval(expr, envir, enclos) :
  ..3 used in an incorrect context, no ... to look in

Jyotirmoy Bhattacharya



More information about the R-help mailing list