[R] Risks of using "function <- package::function" ?

Duncan Murdoch murdoch.duncan at gmail.com
Fri Nov 17 12:25:19 CET 2017


On 17/11/2017 2:30 AM, Jeff Newmiller wrote:
> Obvious?  How about "obscurity"? Just directly use pkg::fun if you have name collision.
> 

One disadvantage of this is that the availability of pkg may not be 
checked until you use it.  Package checks will complain if you haven't 
declared in the DESCRIPTION file that you are importing from pkg, but 
the package will run even if you ignore that check.

But one thing I just realized is that Boris was probably not talking 
about writing a package, he was likely thinking about writing scripts. 
Then DESCRIPTION and NAMESPACE files don't exist, and his student's 
suggestion seems like a reasonable idea, more in the spirit of named 
imports than using "library(pkg)"  or "require(pkg)".

Duncan Murdoch



More information about the R-help mailing list