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

John Fox j|ox @end|ng |rom mcm@@ter@c@
Mon Sep 2 17:34:09 CEST 2024


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/
--



More information about the R-package-devel mailing list