R package dependencies: difference between imports, depends, suggests, enhances

When you want to assemble R codes into a package, you will need to write a file called DESCRIPTION. This file contains some metadata and keywords to be used and some keywords are definitely confusing (at least to me). Here below, I try to emphasize the difference between them (imports, enhances, depends,…).

An advanced DESCRIPTION file would look like:

Package: a_package_name
Type: Package
Title: your clever title
Version: 1.7.6
Date: 2013-07-30
Author: list of authors separated by commas
Maintainer: yourname <username@whatever.org>
Depends: R (>= 2.15.0), RBGL, graph
Suggests: RUnit, BiocGenerics, igraph
biocViews: Bioinformatics, TimeCourse
Description: this package does blablabla
License: GPL-3
LazyLoad: yes
SystemRequirements: anotherPackage version >= 2.2

Package, Type, Title, Version, Date, Author, Maintainer, License are obvious. biocViews contains a list of keywords (bioconductor related).

For the others, it is still a bit confusinf to me but here is what I understood.

  • Depends: list here all packages that are required by your package including version if needed (checked if the packages are installed when calling R CMD INSTALL)
  • Suggests: list here packages that are used in the vignettes (when calling R CMD check)
  • SystemRequirements: list package required but not automatically installed when running R CMD INSTALL

There are two others that could be used as well:

  • Enhances: packages that could improve the performance but not strictly required.
  • Imports: If you use a namespace and added import(“package1”), you don’t need to use “Imports: package1” in the DESCRIPTION file. If you use “Depends”, you don’t need the import. However, using “Imports” is safer than “depends” with respect to scenario where other loaded packages may mask existing functions. Note also that using namespace brings only data or functions apparently. Examples would surely help to explain these different statements. Personally I always use depends and had no issues so far but simply because the packages are simple enough.
Please follow and like us:
This entry was posted in R, Uncategorized and tagged . Bookmark the permalink.

One Response to R package dependencies: difference between imports, depends, suggests, enhances

Leave a Reply

Your email address will not be published. Required fields are marked *