Many R scripts depend on CRAN packages, and most CRAN packages in turn depend on other CRAN packages. If you install an R package, you'll also be installing its dependencies to make it work, and possibly other packages as well to enable its full functionality.
My colleague Andrie posted some R code to map package dependencies a couple of months ago, but now you can easily explore the dependencies of any CRAN package at MRAN. Simply search for a package and click the Dependencies Graph tab. Here's a very simple one: the foreach package.
The foreach package depends on two others: iterators and codetools, which will be automatically installed for you by install.packages when you install foreach. (We'll duscuss the use of “Suggests” — as here with randomForest — later.) Now let's look at a more complex example: the caret package.
The caret package provides an interface to many of the predictive modeling packages on CRAN, and so it has several dependencies (nine, in fact — you can see the list by clicking on the Dependencies Table tab). But it also Suggests many more packages — these are packages that are not required to run caret, but if you do have them, there are more model types you can use within the caret framework.
Here's a quick overview of the types of dependencies you'll find in the charts and tables on MRAN:
- Imports (red) and Depends (orange). These packages are required to use the package of interest. Their dependencies are also required, and shown in the graph. (As a package user, you don't need to worry about the distinction between Imports and Depends, but if you're interested Hadley Wickham's excellent Guide to R Packages has the details.)
- Suggests (grey). These are packages that add additional functionality to the package of interest, but aren't required to use it. You may find certain functions or options don't work if the Suggested packages are not installed and loaded.
- LinkingTo (black): Only relevant if you are working with compiled code. If you need to have the package installed, it will also be listed as a dependency. (Again, see Guide to R Packages for details.)
- Enhances (blue): Very few packages use this type of link, but if they do it indicates that the package provides optional capabilities in another package. (It's sort of a reverse Suggests.)
MRAN is updated daily, and so the Dependencies Graph is always up-to-date with the latest CRAN packages and their connections. Start exploring at the link below.
MRAN: Explore Packages