The usual advice, when developing R packages, is to always fully qualify package dependencies, rather than importing the namespace.
https://r-pkgs.org/dependencies-mindset-background.html#sec-dependencies-namespace-motivation
The above link spells out the rationale for this, but to summarise:
- if 2 packages expose 2 different functions with the same name, then there is an ambiguity about which one to use.
- Additionally, if the user of a package creates their own function with a colliding name, then the package itself will try to use it, instead of the correct intended function.
However, there is a special package called conflicted which helps to manage these sorts of problems. I always use conflicted for any specific analytical work I am doing. However, can I safely import dependencies inside packages I develop, by using “conflicted”? Do I still have to do lib::func()
?