S4 method implementation for S3 class
You can always check eg the Matrix package to show you how it's done. Cheers Joris
On Sat, Sep 23, 2017 at 6:17 PM, I?aki ?car <i.ucar86 at gmail.com> wrote:
There is formally no such thing as an S3 class. Just S3 objects with a
class attribute. You could extend a base class with an S4 class, like
setClass("IntegerWithUnits", slots=c(units="Units"),
contains="integer"). Sure, that's a disruptive change, but it would be
in the right direction.
Extending base classes is always a risky proposition, as you've
discovered. Ideally you would override every transformation in order
to adjust or carry over the representation accordingly. The problem is
that there's a huge amount of transformations available for base
classes, mostly not encapsulated by generics.
Other possibilities include:
- Convincing someone to make %*% an internal S3 generic
- Promoting %*% to an R-level S3 generic, which would only work with
code that sees your namespace
Hopefully others have better ideas,
Michael
Thanks for your kind help and suggestions, Michael. I think I'll take the last option as a workaround, at least until I evaluate the advantages and drawbacks of a complete redesign. I?aki
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
----------- Biowiskundedagen 2017-2018 http://www.biowiskundedagen.ugent.be/ ----------- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Mathematical Modelling, Statistics and Bio-Informatics tel : +32 (0)9 264 61 79 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]]