Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle dependencies (`Depends:`) of imported packages (`Imports:`)

I'm trying to use Imports: instead of Depends: in the DESCRIPTION files of my packages, yet I still feel I've got some more to understand on this ;-)

What I learned from this post (by the way: awesome post!!!) is that everything my package, say mypkg, imports (say imported.pkg) via Imports: lives in environment imports:mypkg instead of being attached to the search path. When trying to find foo that ships with imported.pkg, R looks in imports:mypkg before traversing the search list. So far, so good.

Actual question

If imported.pkg (imported by mypkg) depends on a certain other package (stated in Depends: section of the package's DESCRIPTION file), do I need to make this very package a Depends: dependency of my package in order for R to find functions of that package? So it seems to me at the moment as otherwise R complains.

Evidence

Seems like simply importing such a package is not enough. As an example, take package roxygen2 (CRAN). It depends on digest while importing a bunch of other packages. I imported it (along with digest as mypkg also needs it) and checked environment imports:mypkg which does list the digest function: "digest" %in% parent.env(asNamespace("mypkg")) returns TRUE

Yet when running roxygenize() from within a function that is part of mypkg, R complains that it can't find digest.

like image 481
Rappster Avatar asked Nov 12 '22 06:11

Rappster


1 Answers

You could have a look at my blog : http://r2d2.quartzbio.com/posts/package-depends-dirty-hack-solution.html Now i have a better and cleaner solution but not published yet. Hope it helps.

like image 96
Karl Forner Avatar answered Nov 15 '22 06:11

Karl Forner