[Rd] NextMethod problem

Gabor Grothendieck ggrothendieck at gmail.com
Sat May 7 20:50:49 CEST 2005


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:


> f.default <- function(x, subset, ...) {
+   subset <- eval(substitute(subset), iris, .GlobalEnv)
+   subset
+ }
> 
> # This one is ok
> f(1, 1:3)
[1] 1 2 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)
function (x, ...) 
UseMethod("subset")
<environment: namespace:base>
> 
> # slightly different f.numeric results in error
> f.numeric <- function(x, ...) NextMethod("f")
> f(1, 1:3)
Error in eval(expr, envir, enclos) : ..1 used in an incorrect context,
no ... to look in
> 
> R.version.string # Windows XP
[1] "R version 2.1.0, 2005-04-18"



More information about the R-devel mailing list