[R] Namespaces of imported packages

Martin Morgan mtmorgan at fhcrc.org
Wed Nov 19 02:29:47 CET 2008


Uwe Ligges <ligges at statistik.tu-dortmund.de> writes:

> Hutchinson,David [PYR] wrote:
>> Hi,
>>  I am trying to build an R package. My existing code makes use of
>> the
>> bitops and chron packages. So I have included statements to import
>> required functionality into the NAMESPACE file using import(). When I
>> run Rcmd build, and error is generated "Error: package 'bitops' does not
>> have a name space"
>>  I exclude the import(bitops) statement from the NAMESPACE file and
>> rebuild without error. I am just curious as to why I get an error when
>> importing bitops into the namespace of the current build? Including
>> chron package builds fine.
>>
>
> Obviously, your version of "chron" has a namespace while your version
> of "bitops" has not ....

Less obviously, it's only possible to 'import' from packages with name
spaces. Roughly, a name space allows a package to be loaded (into the
current R session) without being attached (to the global search path),
'Imports:' in the DESCRIPTION file says to load but not attach the
package. 'import' in the NAMESPACE file says to add the specified
symbols to the symbols that the importing package can find. The
distinction between loading and attaching is not available for
packages without name spaces, so it doesn't make (too much) sense (and
is not implemented, even if it did make sense) to 'Import:' or
'import' from packages without name spaces. Some detail is in the R
news article by Luke Tierney

http://cran.fhcrc.org/doc/Rnews/Rnews_2003-1.pdf

I'm seldom right about these things, so others may well correct me.

Martin Morgan

> Uwe Ligges
>
>
>> Thanks in advance,
>> Dave
>> 	[[alternative HTML version deleted]]
>> ______________________________________________
>> R-help at 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.
>
> ______________________________________________
> R-help at 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



More information about the R-help mailing list