【发布时间】:2014-01-06 01:34:43
【问题描述】:
我正在开发一个 R 包,pk,比如说。我已经成功安装并使用了它,现在我正在尝试借助 devtools 包中的 run_examples 函数清理示例。但是,它在第一个示例中崩溃:
> require(pk)
> require(devtools)
> run_examples("~/[full path]/pk")
Updating pk documentation
Running 45 example files in pk
--------------------------------------------------------------------------------
Loading pk
Running examples in pk-package.Rd
--------------------------------------------------------------------------------
1> ########################################################################
1> ## Simulate a dataset ... blah blah
1> set.seed(1)
1> x = my_pk_fun(a = 1)
Error in eval(expr, envir, enclos) : could not find function "my_pk_fun"
Loading pk
由于我已经加载了我的包(使用require),我还需要做什么才能使my_pk_fun 对run_examples 可见?我检查了my_pk_fun 确实存在于我的 R 会话中。
更新:
根据 Dirk 的评论,我检查了我的命名空间文件,发现它完全是空的。按照documentation 的建议(尽管不推荐),我插入了exportPattern("^[^\\.]"),它似乎应该导出所有功能,包括my_pk_fun。然而,在重复上面的实验后,(a)我得到了同样的错误,(b)命名空间文件的内容被删除了!为什么run_examples 清空我的命名空间文件?
【问题讨论】:
-
您是否通过
NAMESPACE文件导出了my_pk_fun? -
@DirkEddelbuettel,查看更新。