**Thinking inside the box**, and kindly contributed to R-bloggers)

The recent update by Søren Højsgaard’s to

his gRbase

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 `Depends`

.

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

book)

coming second. These are both *recommended* packages which are commonly distributed with R itself.

Next are mvtnorm

and

survival. Our

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 `Imports:`

statement

now provides an alternative to the (older) `Depends:`

. The next

chart displays the same relationship for `Imports:`

:

Now

lattice still leads,

but

Hadleys’s plyr package

grabbed the second spot just before

MASS and

Matrix.

It is interesting to see that the sheer number of `Imports:`

is

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

provide a `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

Rcpp

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

Rcpp

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

magnitude of `Depends`

, `Imports`

and

`LinkingTo`

among CRAN packages for R.

**leave a comment**for the author, please follow the link and comment on their blog:

**Thinking inside the box**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...