

This ends up creating a folder with the same name as your package name with 4 files inside the folder: We can do this using devtools: devtools :: create ( "myfirstpackage" ) The first thing you want to do is create the framework for your R package. Creating the Framework for your First Package We will be using this package to make our lives easier:Īt the time of this post, I am using the versions 1.7.0 and 4.1.0 for devtools and roxygen2 respectively. Hadley Wickham has provided the R community with devtools which helps with building R packages. However I am not a RStudio user (vim and Vim-R-plugin suits all my needs), thus I will be showing how everything works in the R console and the specific code to use (which I assume is what RStudio is running for you in the background). RStudio provides a great interface for creating R packages. I aim to provide information that is “in-between” the two aforementioned resources Giving a slightly more detailed explanation on creating packages from scratch while not going into the great depth that “R packages” does.


This post discusses the typical workflow that I use to generate R packages. R scripts! An R package gives an easy way to distribute your code for others. An R package provides a great consistent documentation structure and actually encourages you to document your functions.

"I wish I'd left this code across scattered. This post is inspired by a hilarious tweet that David Robinson made on June 19th, 2015:
