From maechler at stat.math.ethz.ch  Tue Jun 14 10:13:26 2005
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 14 Jun 2005 10:13:26 +0200
Subject: [Rd] operators as S4 methods
In-Reply-To: <1118733820.21400.100.camel@patudo.azti.local>
References: <1118733820.21400.100.camel@patudo.azti.local>
Message-ID: <17070.37286.869107.835135@stat.math.ethz.ch>

For arithmetic operators,
the most elegant way often is to define so called `group methods'
for the whole group of arithmetic operators.

This actually applies also applies to the old classes and
methods.

One example where we do this is the 'Matrix' package,
see the source, e.g., in 
https://svn.r-project.org/R-packages/Matrix/R/dMatrix.R
	
Note that for a namespaced package, on also needs to import the
group generics from the 'methods' package in NAMESPACE:

## Currently, group generics need to be explicitly imported:
importFrom("methods", Arith, Compare, Math, Math2, Summary, Complex)


Martin Maechler, ETH Zurich


>>>>> "Iago" == Iago Mosqueira <imosqueira at suk.azti.es>
>>>>>     on Tue, 14 Jun 2005 09:23:40 +0200 writes:

    Iago> Dear all,
    Iago> I need to re-define some mathematical operators (+, *, /, etc) for an S4
    Iago> class based on array. All references I have found (S Programming, Green
    Iago> Book) show how to define S3 methods for this (like in page 89 of S
    Iago> Programming for "-.polynomial"). What is the preferred S4 way for doing
    Iago> this? I hope I haven't missed some obvious piece of documentation.

    Iago> Many thanks,

 
    Iago> Iago Mosqueira

    Iago> ______________________________________________
    Iago> R-devel at r-project.org mailing list
    Iago> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] operators as S4 methods
Martin Maechler