devtools

Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge

The aim of devtools is to make package development easier by providing R functions that simplify common tasks.

An R package is actually quite simple. A package is a template or set of conventions that structures your code. This not only makes sharing code easy, it reduces the time and effort required to complete you project: following a template removes the need to have to think about how to organize things and paves the way for the creation of standardised tools that can further accelerate your progress.

While package development in R can feel intimidating, devtools does every thing it can to make it less so. In fact, devtools comes with a small guarantee: if you get an angry e-mail from an R-core member because of a bug in devtools, forward me the email and your address and I’ll mail you a card with a handwritten apology.

devtools is opinionated about package development. It requires that you use roxygen2 for documentation and testthat for testing. Not everyone would agree with this approach, and they are by no means perfect. But they have evolved out of the experience of writing over 30 R packages.

I’m always happy to hear about what doesn’t work for you and where devtools gets in your way. Either send an email to the rdevtools mailing list or file an issue at the GitHub repository.

Updating to the latest version of devtools

You can track (and contribute to) the development of devtools at https://github.com/hadley/devtools. To install it:

  1. Install the release version of devtools from CRAN with install.packages("devtools").

  2. Make sure you have a working development environment.
  3. Install the development version of devtools.

R devtools::install_github("hadley/devtools")

Package development tools

All devtools functions accept a path as an argument, e.g. load_all("path/to/path/mypkg"). If you don’t specify a path, devtools will look in the current working directory - this is recommended practice.

Frequent development tasks:

Building and installing:

Check and release:

Other tips

I recommend adding the following code to your .Rprofile:

.First <- function() {
  options(
    repos = c(CRAN = "https://cran.rstudio.com/"),
    browserNLdisabled = TRUE,
    deparse.max.lines = 2)
}

if (interactive()) {
  suppressMessages(require(devtools))
}

See the complete list in ?devtools

This will set up R to:

There are also a number of options you might want to set (in .Rprofile) to customise the default behaviour when creating packages and drafting emails:

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.