[Rd] dumpMethod/getMethod on methods in packages

From: Kasper Daniel Hansen <khansen_at_stat.berkeley.edu>
Date: Mon, 14 Dec 2009 16:42:24 -0500

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)


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)


All 5 lines for copy and paste:

dumpMethod("rowSums", "ngCMatrix", file = "") getMethod("rowSums", "ngCMatrix")
findMethod("rowSums", "ngCMatrix", where = .GlobalEnv) getMethod("rowSums", "ngCMatrix", where = .GlobalEnv)

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 14 Dec 2009 - 21:45:48 GMT

This archive was generated by hypermail 2.2.0 : Mon 14 Dec 2009 - 22:32:35 GMT