使用roxygen2记录函数时,可以将示例放在单独的文件中.
请参阅此处:http: //r-pkgs.had.co.nz/man.html"您可以将它们放在单独的文件中,并使用@example path/relative/to/packge/root,而不是直接在文档中包含示例将它们插入文档中."
在这里:http://roxygen.org/roxygen2-manual.pdf
例如
#' Add together two numbers.
#'
#' @param x A number.
#' @param y A number.
#' @return The sum of \code{x} and \code{y}.
#' @example /path/to/example/add.R
add <- function(x, y) {
x + y
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:应该使用什么路径来存储示例R文件?
氧气中使用的示例的适当位置是:
inst/examples/
Run Code Online (Sandbox Code Playgroud)
氧气线应为:
#' @example inst/examples/add.R
Run Code Online (Sandbox Code Playgroud)
这是好习惯吗?我认为是这样,因为:
| 归档时间: |
|
| 查看次数: |
405 次 |
| 最近记录: |