Skip to content

ellipsis problem

3 messages · Tyler Smith, Duncan Murdoch

#
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
#
On 5/4/2009 2:55 PM, tyler wrote:
This looks like another manifestation of the following bug:

     o	The ... argument was not handled properly when ... was found
	in the enclosure of the current function, rather than in the
	function header itself.	 (This caused integrate() to fail in
	certain cases.)

which has recently been fixed in R-patched.  I haven't traced through 
it, but I do see the same error as you in 2.9.0, but not in 2.9.0 patched.

Duncan Murdoch
I think the only thing you are doing wrong is not keeping up to date 
with the latest patches.

Duncan Murdoch
#
Duncan Murdoch <murdoch at stats.uwo.ca> writes:
[...]
Ok, thanks. I've updated to 2.9.0, but we don't have the patched version
packaged for Debian yet. I can work around the problem until we do.

Cheers,

Tyler