Pink Iguana

Home » Code » Hadley Wickham

Hadley Wickham


Hadley Wickham, Advanced R programming, here. It’s Advanced and has a Philosophy.

Package development philosophy

This book espouses a particular philosophy of package development – it is not shared by all R developers, but it is one connected to a specific set of tools that makes package development as easy as possible.

There are three packages we will use extensively:

  • devtools, which provides a set of R functions that makes package development as easy as possible.
  • roxygen2, which translates source code comments into R’s official documentation format
  • testthat, which provides a friendly unit testing framework for R.

Other styles of package development don’t use these packages, but in my experience they provide a useful trade off between speed and rigour. That’s a theme that we’ll see a lot in this chapter: base R provides rigorous tools that guarantee correctness, but tend to be slow. Sometimes you want to be able to iterate more rapidly and the tools we discuss will allow you to do so.

A package doesn’t need to be complicated. You can start with a minimal subset of useful features and slowly build up over time. While there are strict requirements if you want to publish a package to the world on CRAN (and many of those requirements are useful even for your own packages), most packages won’t end up on CRAN. Packages are really easy to create and use once you have the right set of tools.

Anytime you create some reusable set of functions you should put it in a package. It’s the easiest path because packages come with conventions: you don’t need to figure them out for yourself. You’ll start with just your R code in the R/ directory, and over time you can flesh it out with documentation (in man/), compiled code (in src/), data sets (in data/), and tests (ininst/tests).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: