“找不到功能”;在CMD检查期间的Roxygen示例中 [英] "Could not find function" in Roxygen examples during CMD check
问题描述
我正在RStudio中对一个软件包进行CMD检查,其中一部分分析了内联Roxygen文档中的 @examples
。
我遇到此错误:
正在检查示例...错误
正在运行示例在 packagename-Ex.R中失败
该错误最有可能发生在:
> base :: assign(。ptime,proc.time(),pos = CheckExEnv)
> ###名称:checkDate
> ###标题:确保日期字符串是有效日期
> ###别名:checkDate
>
> ### **示例
>
> checkDate( 2017-05-06)
错误:找不到函数 checkDate
在我的.R文件中,文档定义为:
#'确保日期字符串是有效日期
#'
#'@param dateString字符串(例如 2017-12-04)。
#’@return TRUE或FALSE(如果为FALSE,则发出警告)。
#'@examples
#'checkDate( 2017-05-06)
#'checkDate( 2017-05-40)
我正在使用devtools 1.13.2和roxygen2 6.0.1,我认为它们在发布时都是最新的。 / p>
我还有其他使用相同的devtools / roxygen2组合的软件包,但从未见过它无法在 @examples $ c中找到函数名称$ c>在其范围内。
其他人似乎也经历过类似的事情,例如对这个问题,但我看不到有人说如何解决。
我的猜测是,您需要在Roxygen注释中#'@export
函数,否则该函数不会导出到包的名称空间,也找不到它。
I'm running a CMD check on a package in RStudio, part of which analyses the @examples
in the inline Roxygen documentation.
I'm getting this error:
checking examples ... ERROR
Running examples in ‘packagename-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: checkDate
> ### Title: Ensure that a date string is a valid date
> ### Aliases: checkDate
>
> ### ** Examples
>
> checkDate("2017-05-06")
Error: could not find function "checkDate"
Within my .R file, the documentation is defined as:
#' Ensure that a date string is a valid date
#'
#' @param dateString A string (eg. "2017-12-04").
#' @return TRUE or FALSE (and a warning if FALSE).
#' @examples
#' checkDate("2017-05-06")
#' checkDate("2017-05-40")
I am using devtools 1.13.2 and roxygen2 6.0.1, both of which I believe to be up-to-date at time of posting.
I have other packages using this same devtools/roxygen2 combination but have never before seen it fail to find a function name in @examples
within its scope.
Someone else seems to have experienced something similar as an update to this question, but I can't see that anyone says how to fix it.
My guess is that you need to #' @export
the function in the Roxygen comment, otherwise the function is not exported to the namespace of the package and it cannot be found.
这篇关于“找不到功能”;在CMD检查期间的Roxygen示例中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!