“ namespaceExport(ns,导出)中的错误:未定义的导出”是什么意思?意思? [英] What does "Error in namespaceExport(ns, exports) : undefined exports" mean?
问题描述
构建软件包时,出现错误
When building a package, I got the error
Error in namespaceExport(ns, exports) :
undefined exports: FooBarBaz
这是什么意思,我该如何解决?
What does this mean, and how do I fix it?
推荐答案
当您尝试导出不存在的对象时,会发生此错误。也就是说,包 NAMESPACE
文件包含以下行
This error occurs when you try to export an object that doesn't exist. That is, the package NAMESPACE
file contains the line
export(FooBarBaz)
但 FooBarBaz
不存在
可能会发生此错误的一种情况是,当您尝试为多个功能创建通用帮助页面时使用 roxygen2
。在下面的示例中, f
和 g
是相关功能,将记录在 WidgetUtils
页面。
One case where this error can occur is when you are trying to create a common help page for several functions using roxygen2
. In the example below, f
and g
are related functions to be documented in the WidgetUtils
page.
#' Widget-related functions
#'
#' Utility functions to assist working with widgets.
#' @param x An input.
#' @return A value.
#' @name WidgetUtils
#' @export
NULL
#' @rdname WidgetUtils
#' @export
f <- function(x)
{
x + 1
}
#' @rdname WidgetUtils
#' @export
g <- function(x)
{
x - 1
}
此代码块包含在 WidgetUtils
roxygen块中的 @export
标签。这告诉roxygen在 NAMESPACE
文件中生成导出行,但是它的值是 NULL
,所以没有什么要出口。通过删除 @export
行,使代码可以正常工作。
The mistake in this code chunk is the inclusion of the @export
tag in the WidgetUtils
roxygen block. This tells roxygen to generate the export line in the NAMESPACE
file, but its value is NULL
, so there is nothing to export. By removing the @export
line, so the code will work correctly.
这篇关于“ namespaceExport(ns,导出)中的错误:未定义的导出”是什么意思?意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!