I have already read following two discussion:
Roxygen2 - how to properly document S3 methods
S3 method consistency warning when building R package with Roxygen
And following two tutorial:
http://cran.r-project.org/doc/manuals/R-exts.html#Generic-functions-and-methods
http://adv-r.had.co.nz/S3.html,
but my problem is still not solved. Here are details:
I want to define a S3 method of plot() generic in a package, my code is:
#' description
#'
#' more details
#'
#' @param x "test" object
#' @param label parameter one
#' @param log parameter two
#' @param ... graphical parameters to plot
#'
#' @examples
#' plot(a)
#'
#' @export
plot <- function(x, label=TRUE, log=TRUE, ...){
UseMethod("plot")
}
#' @export
plot.test <- function(x, label=TRUE, log=TRUE, ...){
# some code
}
After running devtools::check()
, I will get following warning:
checking S3 generic/method consistency ... WARNING
plot:
function(x, log, ...)
plot.test:
function(x, label, log, ...)
See section ‘Generic functions and methods’ in the ‘Writing R
Extensions’ manual.
Look like the parameter label
disappear, I tried exchange the position of parameter log
and label
, any parameter after x
will disappear in line function(x, log, ...)
, so how to fix this?