Create your own R Package
Philippe De Brouwer · 2020
Create your own R Package package creationWhile this book focuses on the work-flow of the data scientist and it is not a programming book per se; it still makes a lot of sense to introducing you to building your own package.A package package is an ideal solution to keep together the functions and data that you need regularly for specific tasks.Of course, it is possible to keep these functions in a file that can be read in via the function source(), but having it all in a package has the advantage of being more standardized, structured and easier to document and so it becomes more portable so that also others can use your code.Eventually, if you have built something great and unique then it might be worth to share it via the "Comprehensive R Archive Network" (CRAN). 1 source() Further information -More on creating packagesThis chapter provides only a quick introduction.More information can be found online, for example http://r-pkgs.had.co.nz, which is the website version of Hadley Wickham's book "R-Packages" -see Wickham (2015). devtools roxygenBefore we can get started, we need to install two packages first: devtools -that provides the essentials to build the package -and roxygen -that facilitates the documentation.This is done as follows:install.packages("devtools") install.packages("roxygen2")devtools is the package that is the workhorse to develop packages, it is built and designed to make the process of building packages easier.For readers that use C++, it might suffice to say that roxygen2 is the equivalent in R for Doxygen. 2 This means that roxygen2 will be able to create documentation for R-source code if that code is documented according to a specific syntax.1 The link to submit a package is: https://cran.r-project.org/submit.html.2 Doxygen is the de facto standard tool to generate documentation directly form C++ source code.This is achieved by annotating the code in a specific way.doxygen also supports other languages such as C, C#, PHP, Java, Python, IDL, Fortran, etc.Its website is here: http://www.doxygen.nl.