Counting CRAN Package Depends, Imports and LinkingTo
The recent update by Søren Højsgaard's to
package for graphical models made it the 75th package to depend on our
Rcpp package for R
and C++ integration. So in a lighthearted weekend moment, I
tweeted about gRbase being number 75 for Rcpp
to which Hadley replied, asking if Rcpp was in
fact number one among R package
Far from it, and I immediately replied listing lattice and
Matrix as packages with way more other packages depending upon them.
But as the question seemed deserving of a bit more analysis, I spent a few minutes
on this and prepared three charts listing package in order of reverse
Depends, reverse Imports and reverse LinkingTo.
First off, the reverse
Depends:. This is the standard means of
declaring a dependence of one package upon another.
Unsurprisingly, the MASS package from the
classic Venables and Ripley
book comes first, with Deepayan Sarkar's powerful
lattice package (also
covered in a
coming second. These are both recommended packages which are commonly distributed with R itself.
Next are mvtnorm
Rcpp is up there in
the top-ten, but not a frontrunner.
With the advent of namespaces a few R releases ago, it became possible to
import functions from other packages. So the
now provides an alternative to the (older)
Depends:. The next
chart displays the same relationship for
lattice still leads,
Hadleys's plyr package
grabbed the second spot just before
It is interesting to see that the sheer number of
still not where the
Depends: are. On the other hand, we see a
number of more recent packages popping up in the second chart. This may
reflect more recent coding practices. It will be interesting to see how this
stacks up over time when we revisit this chart.
Lastly, we can also look at
LinkingTo:, a declaration used to
C/C++-level dependency at the source code level. We use
this in the
Rcpp family to
provide automatic resolution of the header files needed to compile against
our packages. And unsurprisingly, because packages using
actually use its API (rather than R functions), the package is a little ahead
of others. In the package we find three more packages of the
family, but only a limited number of other packages as
C/C++-level dependencies are still somewhat rare in the R universe.
There are also fewer packages overall making use of this mechanism.
One could of course take this one level further and sum up dependencies in a
recursive manner, or visualize the relationship differently. But these
dotchart graphs provide a first visual description of the
LinkingTo among CRAN packages for R.