I am making a package where I want to define a new method for plot. I am using roxygen in-source documentation. This question seems very similar to: How to properly document a S3 method of a generic from a different package, using Roxygen? and Roxygen2 - how to properly document S3 methods but I still cannot get it to work.
The relevant parts that are causing me trouble are:
#' Generic plot method
#'
#' @param x \dots
#' @param ... \dots
#' @export
plot <- function(x, ...) UseMethod("plot")
#' Default plot method
#'
#' @param x \dots
#' @param ... \dots
#' @importFrom graphics plot
#' @method plot default
#' @S3method plot default
plot.default <- function(x, ...) graphics::plot(x, ...)
#' Plotting function for ABI object
#'
#' Description.
#'
#' @param x ABI object as generated by newABI.
#' @param base Character. Bases to look at.
#' @param ... Other options passed to plot().
#' @return Nothing. Side-effect: plots graphs.
#' @method plot ABI
#' @S3method plot ABI
plot.ABI <- function(x, base, ...) {
#Overly simplified
plot(1, 1, main = base)
}
When I run this and investigate methods(plot), there is no method defined for ABI objects. Accessing the function by ABI:::plot (ABI is the name of the package) does work. Using :: does not.
During the package build check, there is a warning:
* checking S3 generic/method consistency ... WARNING
plot:
function(x)
plot.ABI:
function(x, base, ...)
See section ‘Generic functions and methods’ of the ‘Writing R
Extensions’ manual.
It seems that there is a disagreement in arguments. But I don't understand this, since the generic has arguments x and ... and so does my ABI method (in addition to base).
So there are two problems, which I hope stem from the same issue: The plot.ABI method is not exported and the package check throws a warning.
How do I solve this?
@S3method
does.@method
is just used to document the function. – Provenience