简体   繁体   English

R包 - 我应该导入`methods`包吗?

[英]R packages - should I import the `methods` package?

I'm using setRefClass to create classes and since is part of the methods package, I presumed you need to declare this dependency as an import . 我正在使用setRefClass来创建类,因为它是methods包的一部分,我假设您需要将此依赖项声明为import

However, the following minimal example fails Rcmd.exe check when import ing methods : 但是, import methods时,以下最小示例无法Rcmd.exe check

#' @docType package
#' @import methods
A <- setRefClass("A")

with the following error (my package is called Test ): 出现以下错误(我的包名为Test ):

==> Rcmd.exe check Test_1.0.tar.gz

<Lots of checks here...>

* checking package dependencies ... ERROR
Namespace dependency not required: 'methods'

See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.

Exited with status 1.

So from what I can make out, it appears I'm being told to remove the import for methods and so keep hidden the package's dependency on methods . 所以从我可以看出,似乎我被告知删除methodsimport ,因此保持隐藏包对methods的依赖。 Is my interpretation correct and if so, why hide the dependency on methods ? 我的解释是否正确,如果是,为什么要隐藏对methods的依赖?

My setup: 我的设置:

  • Roxygen2 3.0.0 Roxygen2 3.0.0
  • R: 3.0.2 (Frisbee Sailing) R:3.0.2(飞盘航行)
  • IDE: RStudio 0.98.490 IDE:RStudio 0.98.490
  • OS: Windows 8.1 操作系统:Windows 8.1

经过更多的狩猎,我意识到,在我的匆忙中,我忘了在我的DESCRIPTION文件中添加Imports: methods

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

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