0

I would like to document a new method for the plot generic. The question is, how to document a new method for a standard generic.

When running

devtools::check(document = FALSE)

I get the warning:

Undocumented S4 methods:
     generic 'plot' and siglist 'my_new_class'

Here is my code (R 4.0.3, roxygen2 7.1.1):

#' Plot a new class
#' 
#' Dummy text
#' 
#' @param x An object of class \code{\link{my_new_class}}.
#' @param y Not used.
#' @param ... Plot parameters forwarded.
#' @return A plot object.
#' @export
methods::setMethod("plot",
                   c(x="my_new_class"),
                   function(x, ...){
                     new_plot_func(x)
                   })

I already looked at the following similar posts, but could not adapt it to my problem:

New method for plot - how to export?

How to properly document S4 "[" and “[<-“ methods using roxygen?

I already tried using @rdname and @alias.

Daniel R
  • 57
  • 5
  • A similar question was already asked in a comment of [this answer](https://stackoverflow.com/a/7423698/12517337) but not answered. – Daniel R Feb 16 '21 at 15:06

1 Answers1

1

I found the answer to the problem myself, which runs devtools::check(document = FALSE) without warnings.

#' Plot a new class
#' 
#' Dummy text
#' 
#' @param x An object of class \code{\link{my_new_class}}.
#' @param y Not used.
#' @param ... Plot parameters forwarded.
#' @return A plot object.
#' @export
methods::setMethod("plot",
                   c(x="my_new_class", y="missing"),
                   function(x, y, ...){
                     new_plot_func(x, ...)
                   })

Apparently, an unused argument in an existing generic has to be set as "missing" in setMethod.

Daniel R
  • 57
  • 5