On 5/4/2009 2:55 PM, tyler wrote:> 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:
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
>
> 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?
I think the only thing you are doing wrong is not keeping up to date
with the latest patches.
Duncan Murdoch
>
> Thanks,
>
> Tyler
>
> R version 2.8.1 (2008-12-22)
> Debian Testing
>