ABSTRACT

The success of R is due, in a large part, to the contributions of users.1 This chapter tells you how to create a package, with tests, so you can contribute too.

Making packages is mostly easier than you think: it’s mostly just a case of putting your files in a specific, well-defined file structure and clicking the “build” button in your IDE. There is a bit of an art to it, however, particularly if you want to do something more advanced. A full reference for how to make packages is way beyond the scope of this book; we’ll just look at the very basics here. If you want to know more, Learning R [4] has a chapter that takes you step-by-step through making your first package, and R Packages [25] by Hadley Wickham is a wonderful, thorough guide to the subject. The official documentation, Writing R Extensions, isn’t quite as easy to read, but contains many explanations of all the technicalities of package creation, and details of what is allowed and what is forbidden. Of course, when things go wrong, programming question and answer site Stack Overflow [19], and the R-package-devel [20] mailing list are good sources of solutions.