[R] ellipsis problem

tyler tyler.smith at mail.mcgill.ca
Mon May 4 20:55:11 CEST 2009


Hi,

I'm confused about the use of ellipsis in function arguments. I'm trying
to write a wrapper for plot to automate the combination of plot() and
points() calls for a data.frame. Some arguments seem to get passed
through to the inner plot, while others cause an error:

 Error in eval(expr, envir, enclos) : 
  ..1 used in an incorrect context, no ... to look in

As a minimal example:

tmp <- data.frame(Y = sample(1:10, 40, replace = TRUE),
                  X = sample(1:10, 40, replace = TRUE))

myplot <- function(x, ...) {
  plot(Y ~ X, data = x, ...)
}

myplot(tmp) ## works fine
myplot(tmp, tcl = 1) ## works fine

myplot(tmp, tcl = -0.1)
Error in eval(expr, envir, enclos) : 
  ..1 used in an incorrect context, no ... to look in

myplot(tmp, mgp = c(3, 0.5, 0))
Error in eval(expr, envir, enclos) : 
  ..1 used in an incorrect context, no ... to look in

plot(Y ~ X, data = tmp, mgp = c(3, 0.5, 0)) ## works
plot(Y ~ X, data = tmp, tcl = -0.1) ## works

What am I doing wrong?

Thanks,

Tyler

R version 2.8.1 (2008-12-22)
Debian Testing

-- 
What is wanted is not the will to believe, but the will to find out,
which is the exact opposite.           --Bertrand Russell




More information about the R-help mailing list