使用data()的R包名称空间问题-找不到数据集 [英] R package namespace issue using data() -- data set not found

查看:708
本文介绍了使用data()的R包名称空间问题-找不到数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,试图在我自己的一个软件包中导入一个软件包(即"robfilter").我要使用的其中一种方法adore.filter在此行失败:

I've hit an issue trying to import a package (namely, 'robfilter') inside one of my own packages. One of its methods that I am trying to use, adore.filter, is failing at this line:

data(critvals)

出现错误未找到数据集临界值"".

With error 'data set 'critvals' not found'.

如果我通过require(robfilter)加载库,该函数将正常运行.但是,这意味着要使用调用adore.filter的自定义程序包,我将必须加载自己的程序包,然后加载robfilter.这不是一个大问题,但有点烦人.

The function works fine if I load the library via 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. Not a huge problem but slightly annoying.

我不确定问题是否是我需要做一些额外的步骤才能使包中可见临界点,或者包作者可能需要做一些事情(并且尚未完成) )在其包名称空间中添加临界值; robfilter NAMESPACE文件中没有临界"迹象.我以前从未遇到过这个问题,也不太了解在包内使用data()应该如何工作.

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. I haven't encountered this issue before and don't really understand how the use of data() inside a package is supposed to work.

推荐答案

据我所知,有两种解决方案:

There are two solutions as far as I know:

  • 请让robfilter维护者将robfiler所需的数据放入robfilter的内部数据文件中. (R/sysdata.rda)
  • 或者使您的软件包依赖robfilter

因此,如果将robfilter放入描述文件的depends部分中,则此方法有效.但是就我而言(都是我的软件包),我试图避免Depends解决方案,因为它会加载导入的软件包,并且其他任何软件包都将依赖于其导入的软件包...请参阅我的

So it works if you put robfilter in the depends section of your description file. 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.

这篇关于使用data()的R包名称空间问题-找不到数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆