Displaying 2 results from an estimated 2 matches for "defenv".
Did you mean:
defend
2006 May 19
1
UseMethod infelicity
...(lm)
...
> mycoef <- function(object, ...) UseMethod("coef", object)
> mycoef(lm.D9)
Error in mycoef(lm.D9) : no applicable method for "coef"
which is pretty surprising, as coef has a default method.
After a bit of digging, this comes from do_usemethod having
defenv = environment where the generic was defined */
defenv = ENCLOS(env);
so it is assuming that UseMethod() is called within the defining generic
for its first argument. That plainly does not need to be true, e.g.
> coefficients
function (object, ...)
UseMethod("coef")
<environ...
2008 Jul 15
1
methods/namespaces/possible bug
...Non-visible functions are asterisked
Based on this, I think that methods("plot") should return
plot.function, so I am almost ready to take the bug word in my mouth.
When I debug the methods function it gets to the line
S3reg <- ls(get(".__S3MethodsTable__.", envir = defenv), pattern =
name)
where it searches the .__S3MethodsTable__. object. Consulting the help
page it seems that this object is part of the namespace functionality.
My guess is that something goes wrong because function is a reserved
word?
Kasper
This has been tested under R-2.7.1 on Mac OS X a...