[Rd] S3 methods with full name in documentation?
murdoch.duncan at gmail.com
Wed Mar 21 02:43:22 CET 2012
On 12-03-20 4:40 PM, Spencer Graves wrote:
> Is there a recommended way to inform "R CMD check" that a
> function like "as.numeric" is NOT a method for the S3 generic function
> "as" for objects of class "numeric"?
> I ask, because I'm getting "NOTE" messages for many function
> names like this (e.g., "density.fd" in the "fda" package): If there
> were a way to tell "R CMD check" that a function name is NOT a method
> for an S3 generic, it would make it easier for me to see the messages I
> should take seriously.
I don't think so. The problem you are seeing is that "density" is a
generic, so density.fd looks like a method for it. In fact, if you
define an object of class "fd" and call density() on it while fda is
attached, your density.fd function will be called:
> x <- structure(1, class="fd")
Error in inherits(WfdParobj, "fdPar") :
argument "WfdParobj" is missing, with no default
So in fact, density.fd *is* an S3 method, even though you didn't know it.
Nowadays every package has a namespace, and eventually maybe S3 methods
that aren't declared in the namespace as S3 methods won't be recognized
as S3 methods. But for now, the only real way around these warnings is
not to name things in a way that makes them appear to be S3 methods.
More information about the R-devel