[R-pkg-devel] R CHECK warning about new S3 generic/method consistency

2024-03-11 Thread CRAN.r
I'm trying to define a new generic, and keep getting an S3 generic/method 
consistency when running R CHECK. All of the code seems to be working, and I'm 
not getting any note, errors, or other warnings.

This minimal example shows the warning I'm getting. The functions are

  myscale <- function(x, y) UseMethod("myscale")
  myscale.default <- function(x) x

The usage section of the man file is

  \usage{
myscale(x, y)
\method{myscale}{default}(x)
  }

and the NAMESPACE file is

  export("myscale", "myscale.default")
  S3method(myscale, default)

When I build the package and run CHECK, I get

  * checking S3 generic/method consistency ... WARNING
  myscale:
function(x, y)
  myscale.default:
function(x)
  See section 'Generic functions and methods' in the 'Writing R
  Extensions' manual.

As I understand it, there shouldn't be a problem as long as the generic 
function contains all possible arguments of any method, and the methods have 
their arguments in the same order as the generic. It seems that having one 
method with only "x" shouldn't be a problem. I've read the section mentioned in 
the warning, but I can't figure out what's going on. Is any of this wrong?

Jay

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] R CHECK warning about new S3 generic/method consistency

2024-03-11 Thread CRAN.r
On Monday, March 11th, 2024 at 12:43 PM, Diego Hernangómez Herrero 
 wrote:

> Shouldn’t you include the y argument also inmyscale.default ? Your generic is 
> defining that argument as well.

I assume (hopefully correctly) that methods don't need to include all the 
arguments of the generic. I get the same warning if I use "..." instead of y, 
too.

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] R CHECK warning about new S3 generic/method consistency

2024-03-11 Thread CRAN.r
> No, your assumption is backwards. The methods do need to include all
> arguments of the generic. As Writing R Extensions says near the start
> of section 7, "A method must have all the arguments of the generic,
> including … if the generic does."

That's embarrassing. I was worried it was something simple I missed. Thanks for 
pointing that out!

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel