I am writing a R package using devtools. Now I have a generic function plot that can take different classes (e.g. plot.fact, plot.numer, etc.). In the .R file of plot.fact, I use #' comment for documentations in a roxygen way. Besides other items, I specify the following comments:
#' @rdname plot
#' @method plot fact
#' @S3method plot fact
#' @export
However, when I run check('pkg') the following error message appear: Error: bad 'S3method' directive: S3method(plot). Is there anything wrong with how I write the comments? Or do I have to write a plot <- function(x,...) UseMethod("plot") before the function plot.fact? Thanks!
UPDATE
更准确地说,我的plot.fact函数没有一个参数x;相反,它有许多额外的参数来自定义绘图。论据是
plot.fact <- function(x, conf.env=0.95, data.note="", leg.cex=1, ...)
根据哈德利的建议,我使用
#' @rdname plot
#' @method plot fact
#' @export
但是报错还是bad 'S3method' directive……我需要写下来吗
plot <- function(x, conf.env=0.95, data.note="", leg.cex=1, ...) {
UseMethod("plot")
}
在定义之前plot.fact?谢谢!