I have a question on the scope of dot-dot-dot arguments. Consider the following function`foo =
foo <- function(x, ...){
require(classInt);
intvl =
Inside the foo
function, the ellipsis does contain 2 elements. Call this modification to see this.
foo <- function(x, ...){
require(classInt);
print(list(...))
intvl = classIntervals(x, ...);
return(intvl);
}
Once classIntervals
is called, the ellipsis changes, since arguments are matched differently. Here's the signature for that function
classIntervals(var, n, style = "quantile", rtimes = 3, ...,
intervalClosure = "left", dataPrecision = NULL)
In your call that fails, you have three arguments
foo(x, style = 'fixed', fixedBreaks = seq(0, 100, 20))
x
gets matched up to var
through positional matching (i.e., because it's in the first position in the signature in each case).
style
gets matched up to style
, via name matching (because they have the same name, duh).
fixedBreaks
can't be matched by position or name so it ends up in the dots.
Thus the ellipsis contains 1 argument, and the error "The ... list does not contain 2 elements" is correct (if rather silly).
EDIT: Suggested fix to classIntervals
. If you are contacting the author, then suggest replacing lines 42-43
mc <- match.call(expand.dots = FALSE)
fixedBreaks <- sort(eval(mc$...$fixedBreaks))
with
fixedBreaks <- list(...)$fixedBreaks
This is (I think) what they meant, and seemes to solve the silly error message.