简体   繁体   English

使用data()的R包命名空间问题 - 未找到数据集

[英]R package namespace issue using data() — data set not found

I've hit an issue trying to import a package (namely, 'robfilter') inside one of my own packages. 我试图在我自己的一个包中导入一个包(即'robfilter')时遇到了问题。 One of its methods that I am trying to use, adore.filter, is failing at this line: 我试图使用的方法之一adore.filter在这一行失败了:

data(critvals)

With error 'data set 'critvals' not found'. 错误'数据集'未发现'标点'。

The function works fine if I load the library via require(robfilter). 如果我通过require(robfilter)加载库,该函数可以正常工作。 However, this means that in order to use my custom package which calls adore.filter, I will have to load my own package, and then load robfilter. 但是,这意味着为了使用调用adore.filter的自定义包,我将必须加载自己的包,然后加载robfilter。 Not a huge problem but slightly annoying. 不是一个大问题,但有点烦人。

I'm not sure if the problem is that there is an extra step I need to do in order to make critvals visible within my package, or if perhaps there is something the package author needed to do (and hasn't done) to add critvals to its package namespace; 我不确定问题是我是否需要做一些额外的步骤才能在我的包中看到批评,或者是否有包装作者需要做的(并且还没有完成)添加对包名称空间的批评; there is no sign of 'critvals' in the robfilter NAMESPACE file. robfilter NAMESPACE文件中没有“critvals”的迹象。 I haven't encountered this issue before and don't really understand how the use of data() inside a package is supposed to work. 我之前没有遇到过这个问题,也没有真正理解如何在包中使用data()。

There are two solutions as far as I know: 据我所知,有两种解决方案:

  • Either ask the robfilter Maintainer to put the data needed by robfiler in the internal data file of robfilter. 要求robfilter Maintainer将robfiler所需的数据放入robfilter的内部数据文件中。 (R/sysdata.rda) (R / sysdata.rda)
  • Or make your package Depends on robfilter 或者让你的包裹取决于robfilter

So it works if you put robfilter in the depends section of your description file. 因此,如果您将robfilter放在描述文件的depends部分中,它就可以工作。 But in my case (both are my packages), I was trying to avoid the Depends solution as it loads the imported package and also any other package will need to depend ont its imported package... See my question is quite a duplicate of yours but not in the same context. 但在我的情况下(两者都是我的包),我试图避免Depends解决方案,因为它加载导入的包,并且任何其他包将需要依赖于其导入的包...看到我的问题是你的重复但不是在同一个背景下。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM