当方法函数共享公共参数时,我应该如何组织R包代码和文档?

当方法函数共享公共参数时,我应该如何组织R包代码和文档?,r,documentation,organization,R,Documentation,Organization,假设我正在编写一个R包,其中包含函数foo,它有两个类typea和typeb的方法。我的理解是,我将在包脚本文件中包括以下内容: foo <- function(...) UseMethod("foo") foo.typeA <- function(x, common.arg, unique.argA) { #Things foo does with typeA objects } foo.typeB <- function(x, common.arg, uniqu

假设我正在编写一个R包,其中包含函数
foo
,它有两个类
typea
typeb
的方法。我的理解是,我将在包脚本文件中包括以下内容:

foo <- function(...) UseMethod("foo")

foo.typeA <- function(x, common.arg, unique.argA) {
     #Things foo does with typeA objects
}
foo.typeB <- function(x, common.arg, unique.argB) {
     #Things foo does with typeB objects
}

然后只有
foo
页面上的
common.arg
文档?如果我想在方法函数中引用
common.arg
,是否必须从
(例如,对于
参数,您是否在使用
roxygen
?如果是,可以查看
@template
@inheritParams
。如果不是,您可能会想查看自动生成此类文档文件的内容,因为使用简单的Rd语法没有这样的方法。我不是。我希望避免自动生成文档。)通过整合文档来进行优化。也许我必须学习
roxygen
。我最大的问题是,所有的
roxygen
代码都出现在您的所有函数文件中。如果您使用roxygen,您可以。出于文档目的,重复您自己不会有任何伤害。您需要从寻找第一次看你的物品,想知道如何使用它们。对你来说合乎逻辑的东西对别人来说往往是不合乎逻辑的。
foo <- function(..., common.arg) UseMethod("foo")

foo.typeA <- function(x, unique.argA, ...) {
     #Things foo does with typeA objects
}
foo.typeB <- function(x, unique.argB, ...) {
     #Things foo does with typeB objects
}