[R] overloading base function

Gabor Grothendieck ggrothendieck at gmail.com
Tue Oct 20 01:21:59 CEST 2009


Perhaps you could just call it Det.

On Mon, Oct 19, 2009 at 7:16 PM, David van Leeuwen
<david.vanleeuwen at gmail.com> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list