R packages - should I import the `methods` package?
methods, package, r, reference-class
Solution
After more hunting around, I realised that in my haste I forgot to add `Imports: methods` to my `DESCRIPTION` file.
Problem
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`. However, the following minimal example fails `Rcmd.exe check` when `import`ing `methods`: ``` #' @docType package #' @import methods A <- setRefClass("A") ``` with the following error (my package is called `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`. Is my interpretation correct and if so, why hide the dependency on `methods`? My setup: - Roxygen2 3.0.0 - R: 3.0.2 (Frisbee Sailing) - IDE: RStudio 0.98.490 - OS: Windows 8.1