On 20/08/2013 15:51, Jannis wrote:
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?
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.
Thanks a lot
Jannis
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.