[R] Using a NAMESPACE or the Imports field in DESCRIPTION?
mtmorgan at fhcrc.org
Wed Mar 11 17:41:12 CET 2009
Hi Wolfgang --
Wolfgang Koller wrote:
> Hello list,
> I am writing a package which builds on a function ("foo") of another
> package. I only need that particular function. What is the state of the
> art to do this? Do I need a NAMESPACE file in my package? Currently I
> still don't have one. Or can I do this with the Imports field in my
> DESCRIPTION file? Reading chapter 1 of the "Writing R Extensions" manual
> I do not completely understand for what situations these two
> alternatives are intended for. The manual says that with the Imports
> field of DESCRIPTION I can "import the name space" of another package.
> What does that mean? What are the differences between the two
> alternatives? Are there consequences for how I can access function "foo"
> within the code of my package?
It sounds like you want to add Imports: OtherPackage to DESCRIPTION, and
in you NAMESPACE file, in addition perhaps to
if you'd like users of your package to access foo. Using a NAMESPACE can
be very beneficial, especially as your software grows in complexity --
it ensures ready access to the symbols you want (foo, in this case)
without relying on the structure of the user search path. I don't think
adding Imports to DESCRIPTION and adding a NAMESPACE should really be
viewed as 'alternatives' -- add a NAMESPACE, and many of the packages
that you had previously listed in Depends: likely belong more
appropriately in Imports.
> Thanks for some clarifications and recommendations!
> Wolfgang Koller
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M2 B169
Phone: (206) 667-2793
More information about the R-help