hadley/r-pkgs

Chapter on `use_package_doc()` may mislead

asadow opened this issue · 1 comments

According to this issue, use_package_doc() is not intended for importing entire namespaces for heavy use, but only for critical infrastructure. The quote below from this page may lead one (like myself) to place @import dplyr into R/[package name]-package.R if a package makes heavy use of dplyr. Similarly for stringr.

Sometimes you make such heavy use of so many functions from another package that you want to import its entire namespace. This should be relatively rare. In the tidyverse, the package we most commonly treat this way is rlang, which functions almost like a base package for us.

Here is the roxygen tag that imports all of rlang. This should appear somewhere in R/*.R, such as the dedicated space described above [R/[package name]-package.R] for collecting all of your namespace import tags.

I think the book says exactly what we mean: it should be rare to import an entire namespace. But we certainly do it (for us, the example is rlang) and we show how it's done.

If your usage of dplyr and stringr is heavy enough that you want to import those namespaces, than that's your call. I don't see the problem. This is not a matter of absolute correct vs. incorrect behaviour.