【发布时间】:2021-10-19 11:13:47
【问题描述】:
我正在准备包裹。在开发阶段,我想创建一个示例脚本example.R,我可以用它来检查我的包的不同功能。但是,我不希望在更新包时执行我的示例脚本。以下是我面临的挑战:
假设我的example.R 有以下代码:
print("Hello")
如果,我更新并保存我的包:
devtools::document()
# Actual Output: [1] "Hello"
# Desired Output: It should be blank. Code in Example.R script should not be executed
我已经尝试了各种其他选项,但到目前为止都不成功:
- 尝试使用
@examples
#' @examples
print("Hello")
如果,我更新并保存我的包:
devtools::document()
# Actual Output: [1] "Hello"
# Desired Output: It should be blank. Code in Example.R script should not be executed
- 尝试使用
\dontrun{}
#' \dontrun{
print("Hello")
#'}
如果,我更新并保存我的包:
devtools::document()
# Actual Output: [1] "Hello"
# Desired Output: It should be blank. Code in Example.R script should not be executed
似乎唯一可行的方法是注释整个代码:
# print("Hello")
如果,我更新并保存我的包:
devtools::document()
# Actual Output:
# Desired Output: It should be blank. Code in Example.R script should not be executed
评论很有挑战性,因为我有多行代码,我将在开发阶段不断更改和编辑。因此我需要一个更简单的选项。
【问题讨论】:
-
应该是“dontrun”而不是“donotrun”
标签: r package devtools roxygen