8
votes

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?

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
Related: one, two (see question 4), three.tonytonov
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
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
I also get the same error using ggvis in the same way but not other for other packages whose methods I call using ::imanuelcostigan