运行时 R CMD check
我得到了
> checking examples ... ERROR
...
...
> lfqplotter$pca()
Error in inner_join(wide$annotation, xx) :
could not find function "inner_join"
Calls: <Anonymous> -> <Anonymous>
Execution halted
之前有人问过类似的问题。 "Could not find function" in Roxygen examples during CMD check
但在我的例子中,它是一个来自导入包 (dplyr) 的函数,我确实在 DESCRIPTION 文件中的导入下列出了它。
Imports:
dplyr
我知道我可以指定和 @importFrom
子句 roxygen2
.但是因为这个包包含了几十个带有示例的函数,而且很多都使用了 dplyr::inner_join
及其他dplyr
函数,我宁愿不必用数百个 @importFrom dplyr inner_join select etc etc
来填充评论,或添加 @import dplyr
到处。或者,我可以,但我不想在每个 dplyr 函数调用前加上 dplyr::
.是否有任何其他选项可以使示例工作和导入的包功能可见?
回答
根据@Roland 和@Waldi 的回答,我添加了一个 R 文件 AAA_importFrom.R
到项目的一个 block :
#' @importFrom tidyr ...
#' @importFrom dplyr ...
...
#'
NULL
并从函数文档中删除了所有@importFrom 子句。
最佳答案
你还应该有:
importFrom(dplyr,inner_join)
在命名空间中
您可以让 Roxygen 在 NAMESPACE 中创建它:
#' @ImportFrom dplyr inner_join
NULL
在你的包的一个 R 脚本中
关于r - 在包检查中运行示例时出现 "could not find function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62423243/