[Rd] Namespace dependency not required
ligges at statistik.tu-dortmund.de
Sun Mar 18 14:57:03 CET 2012
On 18.03.2012 11:21, Patrick Giraudoux wrote:
> I am working at adding namespace to my packages, carefully following the
> doc "Writing R extensions" and some threads on the web. However I cannot
> find clear explanation about how to best deal with the import or
> importFrom functions in the name space. To make it short:
> To declare dependencies in the description file either after Depends:
> (packages including functions that are called from a package function)
> or after Suggests: (packages that are called eg from the doucmentation
> examples), works well. In this case one does not need to declare import
> in the namespace file.
> However, declaring dependencies sometimes for using only one function in
> a given package looks a bit over the top, and I though I could use
> importFrom in the namespace to deal with that. So removing the
> corresponding declaration in Depends (description file) and declaring
> eg importFrom(splancs, inout) in the namespace always led to:
> * checking package dependencies ... ERROR
> Namespace dependency not required: 'splancs'
> Same thing with import(sp). I have the same trouble if I do not remove
> the declarations in Depends.
> So, I can hardly follow the meaning of the "Writing R extension" doc:
> Packages implicitly import the base namespace. Variables exported from
> other packages with namespaces need to be imported explicitly using the
> directives |import| and |importFrom|. The |import| directive imports all
> exported variables from the specified package(s). Thus the directives
> import(foo, bar)
> specifies that all exported variables in the packages *foo* and *bar*
> are to be imported. If only some of the exported variables from a
> package are needed, then they can be imported using |importFrom|. The
> importFrom(foo, f, g)
> specifies that the exported variables |f| and |g| of the package *foo*
> are to be imported.
> Can anybody tell us the conditions for which import and importFrom
> commands should be used in the NAMESPACE rather than in the Depends and
> Suggests declarations of the description file, and the conditions of
> their applicability (without error message... eg with a working example) ?
If you import from another namespace (which is the recommended way
rather than just relying on search order), do not forget to declare it
as "Imports" in your DESCRIPTION file. Your package depends on the other
one: It could not be loaded without having the other one installed now.
> [[alternative HTML version deleted]]
> R-devel at r-project.org mailing list
More information about the R-devel