且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一个 .Rd 文件中的多个功能

更新时间:2023-12-05 23:24:40

这是我找到的***的解决方法,但如果有更好的结果出现,我很乐意更改已接受的答案...

This is the best workaround I've found, but will be glad to change accepted answer if something better comes along...

##' @name funs
##' @aliases sum1
##' @aliases prod1
##'
##' @title Two functions of x and y
##'
##' @param x =X
##' @param y =Y
##'
##' @note code{funs} is a generic name for the functions documented.
##' cr
##' If called, code{funs} returns its own arguments.
##'
##' @rdname funs
##' @export
funs <- function(x,y) {identity(c(x,y))}
##'
##' @rdname funs
##' @return code{sum1(x,y)} returns x+y
##' @examples
##' sum1(3,4)
##' @export
sum1 <- function(x,y) x+y
##'
##' @rdname funs
##' @return code{prod1(x,y)} returns x*y
##' @examples
##' prod1(3,4)
##' @export
prod1 <- function(x,y) x*y

请注意,格式化避免使用 @usage 以避免造成这种情况 一个可报告的错误.

Note that formatting avoids the use of @usage in order to avoid making this a reportable bug.

我可以在 github 上看到如何更好地解决这个问题.

I can see how this may have been better addressed on github.

使用 @usage 的更好解决方案是添加以下行:

A better solution which does use @usage is to add the following line:

##' @usage funs(x,y) A nominal function of x and y

第一次使用后

##' @rdname funs
##' @export

但是,我试图将数字降到最低.R CMD check 抛出的警告以安抚权力,特别是以下内容:

However I'm trying to minimize the no. of warnings thrown by R CMD check in order to placate the powers that be, in particular the folloiwng:

 Functions with usage entries need to have the appropriate alias
    entries, and all their arguments documented.
    The usage entries must correspond to syntactically valid R code.

这最后可能是我阅读 @usage 文档的错误.

This last may be an error of my reading of documentation for @usage.

非常感谢.