checking examples ... ERROR ... ... > lfqplotter$pca() Error in inner_join-6ren">
gpt4 book ai didi

r - 在包检查中运行示例时出现 "could not find function"

转载 作者:行者123 更新时间:2023-12-05 07:06:34 24 4
gpt4 key购买 nike

运行时 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com