Skip to content

NextMethod problem

2 messages · Gabor Grothendieck

#
Can anyone shed any light on what is going wrong here?
Its based on simplifying some actual code that exists in
model.frame.default.  It looks like a bug to me.  Thanks.

data(iris)

f.default <- function(x, subset, ...) {
  subset <- eval(substitute(subset), iris, .GlobalEnv)
  subset
}

# This one is ok
f(1, 1:3)

# putting an intermediate f.numeric in results in body
# of subset function being returned
f.numeric <- function(x, subset, ...) NextMethod("f")
f(1, 1:3)

# slightly different f.numeric results in error
f.numeric <- function(x, ...) NextMethod("f")
f(1, 1:3)

R.version.string # Windows XP

---

Output:
+   subset <- eval(substitute(subset), iris, .GlobalEnv)
+   subset
+ }
[1] 1 2 3
function (x, ...) 
UseMethod("subset")
<environment: namespace:base>
Error in eval(expr, envir, enclos) : ..1 used in an incorrect context,
no ... to look in
[1] "R version 2.1.0, 2005-04-18"
#
Its probably obvious but just for completeness, I missed the
generic definition in pasting this into my post so I have
added it below:
On 5/7/05, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
function(x, ...) UseMethod("f")