简体   繁体   English

如何清除错误:对象 <some function> 不是&#39;名称空间导出: <some package> &#39;在构建我的R包时出现了什么?

[英]How do I clear Error: object <some function> is not exported by 'namespace:<some package>' which shows up when building my R package?

I am using R Studio to author an R package. 我正在使用R Studio编写R包。 I've set up my R Studio preferences to create Roxygen documentation every time I click on "Build & Reload." 每次点击“Build&Reload”时,我都会设置我的R Studio首选项以创建Roxygen文档。 I created an exported function of the form: 我创建了一个表单的导出函数:

#' @title Dummy function
#'
#' @importFrom stats kurtosis
#' @importFrom magrittr %<>%
#' @importFrom dplyr mutate
#' @param input.df Input data frame
#'
#' @export

dummy.function <- function(input.df)
{
  output.df %<>% mutate(col2 = kurtosis(col1))
  return(output.df)
}

Shortly after hitting "Build & Reload" I realized that kurtosis is contained in the e1071 package, not the stats package. 在点击“Build&Reload”之后不久,我意识到kurtosis包含在e1071包中, 而不是 stats包中。 However, after fixing this in my Roxygen comments, I get the following error whenever I do Build & Reload: 但是,在我的Roxygen评论中解决这个问题之后,每当我进行构建和重新加载时,我都会收到以下错误:

Error: object "kurtosis" is not exported by 'namespace:stats'

It would appear that I've broken my package? 看来我打破了我的包裹? How do I repair it? 我该如何修理?

It turns out that a pitfall of the "Build & Reload" workflow with Roxygen comments being written out on the fly is that the NAMESPACE file is written prior to building the package, but is not repaired or adjusted when making changes to the Roxygen comments. 事实证明,“构建和重新加载”工作流程中存在的Roxygen注释即刻写入的缺陷是NAMESPACE文件是在构建包之前编写的,但在更改Roxygen注释时未进行修复或调整。 It turns out that in the above example, the NAMESPACE file had the following line: 事实证明,在上面的示例中,NAMESPACE文件具有以下行:

importFrom(stats,kurtosis)

This line persisted even after I changed my importFrom Roxygen comment to get kurtosis from e1071 instead of stats. 即使我改变了我的importFrom Roxygen评论以从e1071而不是统计数据获得峰值,这条线仍然存在。 Deleting the offending line from the NAMESPACE file will fix the problem. 从NAMESPACE文件中删除违规行将解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复R中的“错误:&#39;名称空间:dplyr&#39;未导出对象&#39;as_tibble&#39;错误:包&#39;BLANK&#39;的延迟加载失败” - How to fix “Error : object ‘as_tibble’ is not exported by 'namespace:dplyr' ERROR: lazy loading failed for package ‘BLANK’” in R 如何解决 R 包构建中的错误 - How do I get around the error in R package building R:&#39;ggpredict&#39; 不是从 &#39;namespace:predict3d&#39; 导出的对象我试过了,它仍然是包的一部分(见图)我该怎么办? - R: 'ggpredict' is not an exported object from 'namespace:predict3d' I tried it, and it is still part of the package (see pic) what can I do? 在 R 中加载 Lime package 时出现错误“对象 'coef.cv.glmnet' 未由 'namespace:glmnet' 导出” - - error “object ‘coef.cv.glmnet’ is not exported by 'namespace:glmnet' ” while loading Lime package in R - 如何使用R包中尚未导出的函数? - How can I use a function inside an R package that has not be exported? 对于某些功能,导入的软件包不能与R中的软件包一起使用? - Imported packages do not work with my package in R for some functions? “数据”不是从“命名空间:my_package”导出的 object - 'data' is not an exported object from 'namespace:my_package' 在 Kohonen package 中使用 xyf() function 在 R 代码中做一些预测 - use xyf() function in Kohonen package to do some prediction in R code 创建属性 model 时 R 中的 MarkovChain package 错误:错误! 转换矩阵的行不是某个 - MarkovChain package error in R when creating attribution model : Error! Rows of transition matrix do not some one 如何在扩展S4类的R包中解决警告消息(未找到元数据对象;未导出SpatialLinesNULL类) - How to resolve warning messages (metadata object not found; SpatialLinesNULL class not exported) in my R package which extends S4 classes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM