Skip to content

using functions from other packages in own package

2 messages · Jannis, Brian Ripley

#
Dear R community,

I am creating my own package which uses functions from other packages. 
After reading several books/help pages I now would do the following to 
safely use some functions from other packages:

1. list them in Imports: (DESCRIPTION file)
2. put importFrom(packagename, functionname1, functionname2) in NAMESPACE

Apparently this now also works without loading the external package with 
require() or library() inside the function that uses the imported functions.

Is this the recommended way to do this (even if there may be several 
ways...)? Is it save to remove all the library() and require() calls?


Thanks a lot
Jannis
#
On 20/08/2013 15:51, Jannis wrote:
Yes, and CRAN is encouraging people to move to this model.

There is one exception: 'methods' should be in Depends: (and also 
importFrom what you need).  That is because of a bug in 'methods' as to 
where it looks for its own functions, which is at least partially fixed 
in R-patched.