Don't have a view on whether it makes sense in base R or not, but WRE section 7.1 may be helpful to you: https://cran.r-project.org/doc/manuals/R-exts.html#Adding-new-generics. It's not uncommon for packages to want to make base methods generic and the above link provides advice on how to do so. Bob On Thu, Jun 23, 2022 at 12:07 PM Lenth, Russell V <russell-lenth at uiowa.edu> wrote:> Dear R-Devel, > > I noticed that if we run base::svd(x), we obtain an object of class > "list". Shouldn't there be an "svd" class, in case someone (e.g., me) wants > to write methods for singular value decompositions? Note that other > matrix-decomposition routines like qr() and eigen() each return objects > having those names. > > Thanks > > Russ Lenth > Russell-lenth at uiowa.edu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
Lenth, Russell V
2022-Jun-24 00:07 UTC
[Rd] [External] Re: svd() results should have a class
Bob,
I'm not talking about using svd as a generic method. I am talking about a
method FOR svd results, e.g. an S3 method like foo.svd(), for which there
already exist other methods, say foo.default and foo.qr. Currently if I wanted
to do
svdobj <- svd(x)
foo(svdobj)
it would not dispatch correctly because there is no svd class. Instead, it would
be handled by foo.list if it exists, and it is certainly not clear that foo.list
would do the right thing.
Russ
Sent from my iPad
On Jun 23, 2022, at 6:53 PM, Robert Harlow <rharlow86 at gmail.com> wrote:
?
Don't have a view on whether it makes sense in base R or not, but WRE
section 7.1 may be helpful to you:
https://cran.r-project.org/doc/manuals/R-exts.html#Adding-new-generics.
It's not uncommon for packages to want to make base methods generic and the
above link provides advice on how to do so.
Bob
On Thu, Jun 23, 2022 at 12:07 PM Lenth, Russell V <russell-lenth at
uiowa.edu<mailto:russell-lenth at uiowa.edu>> wrote:
Dear R-Devel,
I noticed that if we run base::svd(x), we obtain an object of class
"list". Shouldn't there be an "svd" class, in case
someone (e.g., me) wants to write methods for singular value decompositions?
Note that other matrix-decomposition routines like qr() and eigen() each return
objects having those names.
Thanks
Russ Lenth
Russell-lenth at uiowa.edu<mailto:Russell-lenth at uiowa.edu>
[[alternative HTML version deleted]]
______________________________________________
R-devel at r-project.org<mailto:R-devel at r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[[alternative HTML version deleted]]