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
importFrom(OtherPackage, foo)
in you NAMESPACE file, in addition perhaps to
export(foo)
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.
Martin
Thanks for some clarifications and recommendations!
Wolfgang Koller
______________________________________________
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.
--
Martin Morgan
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
______________________________________________
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.