r - 在包检查中运行示例时“找不到函数”
问题描述
跑步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
之前有人问过类似的问题。 CMD 检查期间 Roxygen 示例中的“找不到函数”
但在我的情况下,它是一个来自导入包 (dplyr) 的函数,我在DESCRIPTION 文件中的Imports 下列出了它。
Imports:
dplyr
我知道我可以@importFrom
用roxygen2
. 但是,由于该包包含数十个带有示例的功能,以及许多使用dplyr::inner_join
和其他dplyr
功能,我宁愿不必在评论中填写数百个@importFrom dplyr inner_join select etc etc
,或者@import dplyr
到处添加。或者,我可以,但我不想在每个 dplyr 函数调用前加上dplyr::
. 是否有任何其他选项可以使示例工作和导入的包功能可见?
回答
根据@Roland 和@Waldi 的回答,我AAA_importFrom.R
在项目中添加了一个 R 文件,其中包含以下内容:
#' @importFrom tidyr ...
#' @importFrom dplyr ...
...
#'
NULL
并从函数文档中删除了所有 @importFrom 子句。
解决方案
你还应该有:
importFrom(dplyr,inner_join)
在命名空间中
您可以通过以下方式让 Roxygen 在 NAMESPACE 中创建它:
#' @ImportFrom dplyr inner_join
NULL
在你的包的一个 R 脚本中
推荐阅读
- wordpress - 如何创建本地 Wordpress 站点的 .json 文件?
- c# - 使用 ASP.NET Core 和 Entity Framework Core 进行集成测试 - 如何在每次测试时恢复数据库中的测试数据?
- django - 在 Django Rest Framework 中创建新对象之前使用序列化器数据获取外部 API 信息
- python - 使用 1D 布尔数组从 3D RGB 图像中提取掩码
- amazon-web-services - 没有卷附加到正在运行的 mysql docker 容器 - AWS Elastic beanstalk 多容器 docker 应用程序
- c# - 作为 Stripe 更新的一部分,如何用 statement_descriptor_suffix 替换 statement_descriptor 参数
- python-3.x - 如何使用循环以及如何将值保存在新变量中
- javascript - 如何将两个下载的数组合并为一个 JSON 数组?
- javascript - 如何将 AWS Mobile Hub 与 NativeScript 结合使用
- css - ios Mobile复选框边框错误