8

I have a package that contains the following package Imports in the DESCRIPTION file:

Imports: lubridate,
    assertthat,
    R6,
    stringr

I don't import these into my package's NAMESPACE using an import(pkgname) or importFrom(pkgname, fn) commands. Rather I refer to these package's functions in my R code using a fully qualified call. Based on my reading of R-ext, this is permissible:

The ‘Imports’ field lists packages whose namespaces are imported from (as specified in the NAMESPACE file) but which do not need to be attached. Namespaces accessed by the ‘::’ and ‘:::’ operators must be listed here...

However, I get the following error when I run devtools::check():

* checking dependencies in R code ... NOTE
Namespaces in Imports field not imported from:
  'R6' 'stringr'
  All declared Imports should be used.
See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.

NB: to confirm, my R code contains fully qualified calls to functions in R6 and stringr (e.g. stringr::str_detect(...) and R6::R6Class(...)).

Why am I getting these notes? And how do I make them go away?

tonytonov
  • 25,060
  • 16
  • 82
  • 98
imanuelcostigan
  • 3,459
  • 3
  • 17
  • 19
  • I'm hiding my post until I'm sure it has correct details. However, I still think adding `importFrom` will remove the note, please try that. – tonytonov Feb 06 '15 at 07:48
  • Related: [one](http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends), [two](http://stackoverflow.com/questions/9893791/imports-and-depends) (see question 4), [three](http://stackoverflow.com/questions/13085481/namespace-dependencies-not-required). – tonytonov Feb 06 '15 at 08:16
  • Thanks @tonytonov. I know about importFrom(), but I don't want to use that mechanism as the R-ext docs suggest I don't need to. The links you've provided don't address my use case. – imanuelcostigan Feb 06 '15 at 08:33
  • Keep in mind you are getting a note, not an error. So if your approach works, leave it be and ignore the note. However, your package will not be accepted on CRAN, they have a strict policy on that. – tonytonov Feb 06 '15 at 08:49
  • I also get the same error using ggvis in the same way but not other for other packages whose methods I call using `::` – imanuelcostigan Jan 24 '16 at 06:49
  • I believe you need at least one import to please R CMD check. But that does not prevent you from using fully qualified calls. – Karl Forner Jan 06 '17 at 10:33
  • Have you checked my above comment ? You could may be close that issue... – Karl Forner Jan 25 '22 at 09:37

0 Answers0