Kasper Daniel Hansen
2009-Dec-14 21:42 UTC
[Rd] dumpMethod/getMethod on methods in packages
There seems to be something wrong with dumpMethod when called on methods defined
in packages (possibly with namespaces). This may be caused by a possible bug in
getMethod.
(see below for a full copy/paste without comments)
First
library(Matrix)
Now compare
dumpMethod("rowSums", "ngCMatrix", file = "")
## Nothing
to
getMethod("rowSums", "ngCMatrix") ## The method
definition
Further inspection suggests that it is related to the where argument to
dumpMethod, the default being where = topenv(parent.frame()) which evaluates (in
this usecase) to .GlobalEnv. I find it interesting to compare
findMethod("rowSums", "ngCMatrix", where = .GlobalEnv) ##
Finds the method in the Matrix package
to
getMethod("rowSums", "ngCMatrix", where = .GlobalEnv) ##
Does not find anything
It seems to me that getMethod is wrong when it does not find anything in the
global environment.
Tested in R-2.10-patched (r50736) and R-devel (r50736)
dumpMethod works fine with example(dumpMethod) where a method gets defined in
the global environment. My usecase was trying to dump a method from a namespace
I had edited with trace(..., edit = TRUE)
Kasper
All 5 lines for copy and paste:
library(Matrix)
dumpMethod("rowSums", "ngCMatrix", file = "")
getMethod("rowSums", "ngCMatrix")
findMethod("rowSums", "ngCMatrix", where = .GlobalEnv)
getMethod("rowSums", "ngCMatrix", where = .GlobalEnv)