[R-pkg-devel] unregistered S3 methods in a package

John Fox j|ox @end|ng |rom mcm@@ter@c@
Mon Sep 2 20:57:58 CEST 2024


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



More information about the R-package-devel mailing list