- If you want to document the method use
@method plot fact
+@export
. - If you don't want to document it, use
@s3method plot fact
.
You shouldn't ever have @method
and @s3method
in the same block.
Question
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
To be more precise, my plot.fact
function does not have a single argument x
; instead, it has many extra parameters to customize the plot. The arguments are
plot.fact <- function(x, conf.env=0.95, data.note="", leg.cex=1, ...)
According to Hadley's suggestion, I use
#' @rdname plot
#' @method plot fact
#' @export
But the error is still bad 'S3method' directive
... Do I need to write down
plot <- function(x, conf.env=0.95, data.note="", leg.cex=1, ...) {
UseMethod("plot")
}
before the definition of plot.fact
? Thanks!
Solution
@method plot fact
+ @export
. @s3method plot fact
. You shouldn't ever have @method
and @s3method
in the same block.