使用Roxygen在同一文件中记录两个S3方法

Bri*_*ggs 23 documentation r roxygen2

我有两种方法用于密切相关的S3泛型(在另一个包中定义),因此我想在同一个Rd文件中记录它们.但是,当我单独记录他们的参数时,我会收到R CMD check关于"文档对象中的重复\参数条目" 的警告

##' Create a ggplot of a Kaplan-Meier Survival curve(s)
##'
##' @param data  A \code{survfit} object returned from \code{\link{survfit}}
##' @param \dots Unused
##' @return A ggplot2 object
autoplot.survfit <- function(data, ...) {
    NULL
}

##' @rdname autoplot.survfit
##' @param data A \code{\link{survfit.fortify}} object returned from \code{\link{fortify.survfit}}
autoplot.survfit.fortify <- function(data, ...) {
    NULL
}
Run Code Online (Sandbox Code Playgroud)

第一个参数必须是data因为这是泛型定义的.但是,对于不同的方法,它的文档是不同的,只是因为它必须是不同的类.我可以有两个单独的文档文件,但它们是紧密耦合的,所以我想将它们保持在一起.我可以data在第一次调用中列出所有可能的类,并且在后续调用中没有任何内容,但这意味着我用第一个函数记录第二个函数而不是将它们全部保存在一起,就像Roxygen一样.

是否有可能通过多种方法获得roxygen来创建合法(不重复参数)?如果没有,处理这种情况的最佳方法是什么?

cbe*_*ica 2

我认为 S3 泛型方法背后的想法是,没有必要对同一参数有不同的描述。

##' @method如果您使用和生成 S3 方法文档,那么从使用部分可以清楚地看出哪些类被接受(对于进行分派的参数)##' @S3method。对于其他参数,我想说需要不同的描述可能表明应该使用不同的参数名称。

所以来自:

##' Create a ggplot of a Kaplan-Meier Survival curve(s)
##'
##' @param data  the object to be plotted
##' @param \dots Unused
##' @method autoplot survfit
##' @S3method autoplot survfit
##' @return A ggplot2 object
autoplot.survfit <- function(data, ...) {
    NULL
}

##' @rdname autoplot.survfit
##' @method autoplot survfit.fortify
##' @S3method autoplot survfit.fortify
autoplot.survfit.fortify <- function(data, ...) {
    NULL
}
Run Code Online (Sandbox Code Playgroud)

我同意roxygen2

Create a ggplot of a Kaplan-Meier Survival curve(s)

Description:

Create a ggplot of a Kaplan-Meier Survival curve(s)

Usage:

     ## S3 method for class 'survfit'
      autoplot(data, ...)

     ## S3 method for class 'survfit.fortify'
      autoplot(data, ...)

Arguments:

    data: the object to be plotted

     ...: Unused

Value:

     A ggplot2 object
Run Code Online (Sandbox Code Playgroud)