Using individual functions from an unloaded package
As time has gone by I find myself loading more and more packages at the beginning of an R session. Just loading the tidyverse loads more packages than used to be my norm. Because of this, I find myself increasingly likely to be hit by function name conflicts. Especially when I did not notice those conflicts during package loading these can create confusing results and strange errors. So I am wondering if I can, in general, just import the particular function I want to use, without loading the package from which it comes.
More precisely, if this_pack
is a package that is locally installed but not loaded, and this_fn()
is an exported function in this_pack, can I safely expect this_pack::this_fn()
to work, and to work in the same way as it would if the entire package were loaded? I know it usually does, but I want to know if there are times I should expect it to fail.
See the answers to related questions for additional information:
I've accepted the answer of user2554330, which I think would not be an answer to the other questions referenced. Still, they provide interesting, and related, information on other reasons to or not to use ::, so I think keeping the cross-reference is probably a good idea. I've incorporated them above.