[R-pkg-devel] unregistered S3 methods in a package
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Wed Sep 4 23:12:09 CEST 2024
I have been reluctant to pipe up on this because I am no expert on the dark corners of the S3 dispatch mechanism, but I think unregistered S3 methods in packages are verboten. Perhaps [1] will shed some light?
[1] https://blog.r-project.org/2019/08/19/s3-method-lookup/
On September 4, 2024 11:21:22 AM PDT, Toby Hocking <tdhock5 using gmail.com> wrote:
>I got this warning too, so I filed an issue to ask
>https://github.com/r-lib/roxygen2/issues/1654
>
>On Mon, Sep 2, 2024 at 2:58 PM John Fox <jfox using mcmaster.ca> wrote:
>>
>> As it turned out, I was able to avoid redefining coef.merMod(), etc., by
>> making a simple modification to the cv package.
>>
>> I'm still curious about whether it's OK to have unregistered S3 methods
>> for internal use in a package even though that's no longer necessary for
>> the cv package.
>>
>> On 2024-09-02 11:34 a.m., John Fox wrote:
>> > Caution: External email.
>> >
>> >
>> > Dear R-package-devel list members,
>> >
>> > I want to introduce several unregistered S3 methods into the cv package
>> > (code at <https://github.com/gmonette/cv>). These methods have the form
>> >
>> > coef.merMod <- function(object, ...) lme4::fixef(object)
>> >
>> > The object is to mask, e.g., lme4:::coef.merMod(), which returns BLUPs
>> > rather than fixed effects, internally in the cv package but *not* to
>> > mask the lme4 version of the method for users of the cv package -- that
>> > could wreak havoc with their work. Doing this substantially simplifies
>> > some of the code in the cv package.
>> >
>> > My question: Is it legitimate to define a method in a package for
>> > internal use without registering it?
>> >
>> > This approach appears to work fine, and R CMD check doesn't complain,
>> > although Roxygen does complain that the method isn't "exported"
>> > (actually, isn't registered).
>> >
>> > Any advice or relevant information would be appreciated.
>> >
>> > Thank you,
>> > John
>> > --
>> > John Fox, Professor Emeritus
>> > McMaster University
>> > Hamilton, Ontario, Canada
>> > web: https://www.john-fox.ca/
>> > --
>> >
>> > ______________________________________________
>> > R-package-devel using r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>______________________________________________
>R-package-devel using r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-package-devel
--
Sent from my phone. Please excuse my brevity.
More information about the R-package-devel
mailing list