[Rd] Creating S3 methods for S4 classes (coming from r-package-devel)
l@wrence@mich@el @ending from gene@com
Thu May 24 18:20:10 CEST 2018
You only have to make an S4 method if there is already an S4 generic.
If there is just an S3 generic, then just define S3 methods on it. I
think we should stay away from defining S4 generics when there is no
good reason for them. Good reasons include multiple dispatch, or a
non-default signature. Neither of those apply in this case.
On Thu, May 24, 2018 at 6:39 AM, Joris Meys <jorismeys using gmail.com> wrote:
> Dear all,
> I asked this question on r-package-devel but Martin Maechler pointed out
> this was more suited on R-devel. So here it goes:
> per the manual, one should create and register both the S3 and a S4 method
> if one needs a method for an S4 class for a function using S3 dispatching.
> This is cumbersome, and not very optimal.
> I was wondering if there's a better way to do this. Currently I recreate a
> generic in my package and create a default method that sends all the other
> classes to the S3 generic, eg:
> setMethod("predict", "ANY", stats::predict)
> I'm not sure if this hasn't any adverse consequences, as it is not the
> recommended approach.
> It would be great if these generics could be made available through stats4.
> If this would be the prefered route, I volunteer to create the patch for
> Any thoughts?
> (Original mail on r-package-devel :
> https://stat.ethz.ch/pipermail/r-package-devel/2018q2/002757.html )
> Joris Meys
> Statistical consultant
> Department of Data Analysis and Mathematical Modelling
> Ghent University
> Coupure Links 653, B-9000 Gent (Belgium)
> Biowiskundedagen 2017-2018
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> [[alternative HTML version deleted]]
> R-devel using r-project.org mailing list
More information about the R-devel