[R] overloading base function

David van Leeuwen david.vanleeuwen at gmail.com
Tue Oct 20 01:16:57 CEST 2009


Hello,

I am trying to write an R package for doing analysis of speaker
recognition systems.  The big thing in this line of research is a
DET-plot (detection Error Trade-off, a ROC plot with qnorm() warped
axes).   My approach has been to make a class "det" and also a
function "det()" that will prepare the data into the right class.

Now loading the library doesn't like me re-defining the determinant
function "det" from the base package.  I have tried to save its
definition using code like

## keep old definition of det()
## det.matrix <- det
det <- function(x, ...) UseMethod("det")
det.default <- base::det

which allows me perfectly fine to use det() as determinant of a
matrix, but still loading the library complains with a
> library(sretools)
Loading required package: fdrtool

Attaching package: 'sretools'


	The following object(s) are masked from package:base :

	 det

Is there a recommended way to do this style of "overloading" (albeit a
completely different kind of function), or am I simply not supposed to
use the name of an existing function in my packages?

Cheers,

---david

-- 
David van Leeuwen




More information about the R-help mailing list