Re: [Rd] import of Namespaces

From: Roger Peng <rpeng_at_jhsph.edu>
Date: Thu 01 Dec 2005 - 19:46:58 GMT

My understanding is of your questions is below:

Matthias Kohl wrote:
> Dear R devels,
>
> let's say I have three packages "pkg1", "pkg2" and "pkg3" which all
> contain new S4 classes and methods. Where "pkg3" depends on "pkg2" and
> "pkg2" depends on "pkg1". Moreover, all three packages have namespaces.
>
> 1) I use ".onLoad <- function(lib, pkg) require(methods)". Do I also
> have to import the namespace of "methods" package?

No.

>
> 2) If I use import("pkg1") in the namespace of "pkg2", does this also
> (correctly) import the S4 classes and methods of "pkg1"? Or do I
> explicitly have to use importClassesFrom resp. importMethodsFrom?

Importing an entire package namespace will import all of the exported classes/methods from "pkg1".

>
> 3) If I import the Namespace of "pkg2" in "pkg3", where the namespace of
> "pkg2" has import("pkg1") (or maybe importClassesFrom,
> importMethodsFrom) and I also want to use S4 classes and methods of
> "pkg1" in "pkg3". Is it sufficient to have import("pkg2") in the
> Namespace of "pkg3" or do I need import("pkg1") and import("pkg2")?

I believe you need to import each separately since the S4 classes/methods from "pkg1" will not be available to you simple because you imported "pgk2" (i.e. I don't think the chain rule applies here).

>
> Many thanks for your help and advice
> Matthias
>

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Dec 02 06:51:09 2005

This archive was generated by hypermail 2.1.8 : Fri 02 Dec 2005 - 02:21:32 GMT