[R-pkg-devel] Documenting courtesy S3 methods

Lenth, Russell V ru@@e||-|enth @end|ng |rom u|ow@@edu
Thu Aug 6 17:12:13 CEST 2020


Thanks, Bert. 

This looks potentially useful as an alternative to the way I currently dynamically register the method. It does seem to require that 'pkg' must actually be installed on the system in order to work, and that pkg would have to be listed in Import. I'd rather not force users to install packages they will never use. I am not sure of this requirement, but I'm sure I could verify it one way or the other using the checking system.

And yes, I could (and do) document within the Details and Examples (and could add a note as well) that users need to use multcomp::cld(). It just seems that actually showing that in the Usage section is by far the clearest way to communicate that requirement.

Russ

From: Bert Gunter <bgunter.4567 using gmail.com> 
Sent: Wednesday, August 5, 2020 9:31 PM
To: Lenth, Russell V <russell-lenth using uiowa.edu>
Cc: r-package-devel using r-project.org
Subject: [External] Re: [R-pkg-devel] Documenting courtesy S3 methods

From WRE:

"As from R 3.6.0 one can also use S3method() directives to perform delayed registration. With
if(getRversion() >= "3.6.0") {
    S3method(pkg::gen, cls)
}
function gen.cls will get registered as an S3 method for class cls and generic gen from package pkg only when the namespace of pkg is loaded. This can be employed to deal with situations where the method is not “immediately” needed, and having to pre-load the namespace of pkg (and all its strong dependencies) in order to perform immediate registration is considered too onerous."
I understand the issue is documentation, but if you took this route, could you not document your S3 method as usual without loading multcomp's (or whatever) namespace. You could include a \note section in the doc saying that the multcomp namespace must be explicitly loaded if your method is to be used (perhaps showing the code to do so)
If I am clearly mistaken about this, feel free to dismiss without reply.

Cheers,
Bert Gunter




More information about the R-package-devel mailing list