[R-pkg-devel] slightly polemic question re R CMD check

Gábor Csárdi c@@rd|@g@bor @end|ng |rom gm@||@com
Sun Mar 8 12:04:44 CET 2020


You can add the ... argument to chop.default(), and then check that
length(list(...)) is zero.

Also, you might be interested in the ellipsis package.

Gabor

On Sun, Mar 8, 2020 at 10:56 AM David Hugh-Jones
<davidhughjones using gmail.com> wrote:
>
> Hi all,
>
> My package defines the following method and generic:
>
> chop <- function (x, ...) UseMethod("chop")
>
> chop.default <- function (x, breaks, labels, extend = NULL, drop = TRUE) {
> ... }
>
> R CMD check then gives a warning:
>
> W  checking S3 generic/method consistency (695ms)
>    chop:
>      function(x, ...)
>    chop.default:
>      function(x, breaks, labels, extend, drop)
>
>    See section ‘Generic functions and methods’ in the ‘Writing R
>    Extensions’ manual.
>
> I can fix this by adding a ... argument to chop.default:
>
> chop.default <- function (x, breaks, labels, extend = NULL, drop =
> TRUE, ...)
>
> But that makes the code less robust because e.g.
>
> chop(x, Breaks = 1:3)
>
> will no longer throw an error from the misspelled argument.
>
> Or I can write:
>
> chop(x, breaks, labels, extend, drop) UseMethod("chop")
>
> but this means I cannot use a different interface for a different method.
>
> This seems like a mistake. (That's the polemic.) Or am I missing a better
> way? (That's the question.)
>
> David
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list