From ggrothendieck at gmail.com  Sat May  7 20:50:49 2005
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sat May  7 20:50:57 2005
Subject: [Rd] NextMethod problem
Message-ID: <971536df05050711507c5c9884@mail.gmail.com>

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"


[Rd] NextMethod problem
Gabor Grothendieck