Question

I have read two recent posts that discuss Depends and Imports

But I have four lingering, related questions:

  1. Suppose I want two packages to also be available to the end-user when they load in my package. Is there a good reason not to use Depends in this context? (The point here is to load all three packages via a command that loads just the one package.)

  2. Is it okay to specify a package in both the Depends and Imports fields?

  3. If a package is listed in Depends, is there a point to also listing it in Imports? Or are the benefits of Imports already negated by using Depends?

  4. Is the following correct? A package should be listed in the Imports field of the DESCRIPTION file if and only if the package is imported (in whole or in part) in the NAMESPACE file.

Thanks much!

David

Was it helpful?

Solution

Couple of points, and I will admit that I also find this confusing at times. But I revisited it recently, and here is my take:

  1. "Depends" is how we used to do things; it is closest to "just loading all three":when your third depends on the other two, all three will get loaded.

  2. With Namespaces, we can also import. That brings in just the stated symbols, which can be data or functions. I use this sometimes; it will not load the other package that you import from but just make the stated symbols available. As such, it is "lighter" than Depends.

  3. If you do Depends, there is no need for Imports.

  4. That is correct: If you use declarations in in NAMESPACE to import symbols from another packages, that other package needs to be listed in Imports: in the DESCRIPTION file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top