[R] Overload standart function

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 14 23:01:37 CEST 2005


On Thu, 14 Apr 2005, [iso-8859-2] Václav Kratochvíl wrote:

> I try to develop my own R package. I have a couple of standart functions 
> like dim() and length() overloaded.

Hmm.  Not with the name dim.Model.  You have defined an S3 method for 
class "Model", possibly not intentionally, and without following the rules 
set out in `Writing R Extensions'.

> #Example
> dim.Model <- function(this) {
>  length(unique(this$.variables));
> }
>
> I built my package, but when I try to load it... This message appears:
> Attaching package 'mudim':
>        The following object(s) are masked _by_ .GlobalEnv :
>         dim.Model,...(etc.)
>
> Any idea, how to hide this message?

See ?library, which has an argument warn.conflicts, and that tells you how 
to do this on a per-package basis.

However, the problem appears to be that you don't want the copies in 
workspace (.GlobalEnv), which should be easy to fix.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list