Devtools::load_all() doesn't load imports in the NAMESPACE

I am working on an internal package. Because I use dplyr a lot it and it is for my own use only, it seems sensible to import it. I added the roxygen tag #' import dplyr to my code and after running devtools::document() the tag import(dplyr) indeed was added to the NAMESPACE file.

I expected that after running devtools::load_all() the functions from dplyr would now be available. However, this is not the case. Functions calling dplyr functions break with "could not find ..." error message. What am I overlooking or misunderstanding? Thanks!

You must use dplyr::function to call a function. If you really want to load dplyr in your project, you can do it with library. However, the latter is not recommended in most cases. If this doesn't work, then dplyr might not be installed.

The devel version of devtools does this, so you can use that if you are really looking for this feature.


Be sure to run devtools::document() after adding the @import directive so the NAMESPACE is properly created.


Thanks for your reply, but I think you are mixing up the Imports field in the DESCRIPTION file with adding import(pkg) to the NAMESPACE. I am referring to the latter, this should load all the functions from the package. In case of the former you should indeed refer to functions with pkg::fun.

Indeed. I guess my response was more of a quick shot missing the point.
Thanks for clarifying. :slight_smile:

Hi @Edwin, I noticed that your example roxygen #' import dplyr was missing the @ in @import, was that part of the problem?