Re: [Rd] S3 methods with full name in documentation?

From: Spencer Graves <>
Date: Wed, 21 Mar 2012 00:11:01 -0700

Hi, Duncan:

On 3/20/2012 6:43 PM, Duncan Murdoch wrote:
> On 12-03-20 4:40 PM, Spencer Graves wrote:
>> Hello:
>> 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")
> > density(x)
> 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.

       Well, yes, I guess I knew that, but I also knew that "density.fd" should not be called with the first argument having class "fd", even more that "as.numeric", which is also recognized as the "numeric" method for the presumed generic function "as". [Yes, I know that "as" does not call methods dispatch such as "UseMethod" called by "density", so "as.numeric" is different from that perspective.]

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

       Thanks. I asked, because I thought there might be something one could do in a NAMESPACE to avoid this. "density.fd" has been around for some time, and picking a different name for it (and similar functions in the fda package) would break too much existing code and impose an unacceptable burden on long-time fda users to justify that option -- similar to "as.numeric".

       Thanks, again.

       Best Wishes,

> Duncan Murdoch mailing list Received on Wed 21 Mar 2012 - 07:13:13 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 21 Mar 2012 - 09:30:31 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive