Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

However, the following minimal example fails Rcmd.exe check when importing 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
like image 279
mchen Avatar asked Feb 04 '14 10:02

mchen


1 Answers

After more hunting around, I realised that in my haste I forgot to add Imports: methods to my DESCRIPTION file.

like image 91
mchen Avatar answered Oct 28 '22 07:10

mchen