

roxgyen2 will not update the DESCRIPTION file. One thing to remember…we will be using roxygen2 for most of our documentation work.

Do not leave the fields with their defaults. The DESCRIPTION file contains basic information on the package. Assuming you use the roxygen2 package, you will not need to create these files by hand, they will be generated by information in the R folder. We will discuss the requirements at length in the Documentation section. The “man” folder contains the files used to create each function’s “help” file (the documentation).

By using RStudio’s package wizard, they created a file “hello.R”, which created a “Hello World” function. R extension) that will run when the package is loaded. R folderĪny R code that will be executed goes in the “R” folder. As this workshop goes on, we will introduce more options for directories and files. These are the absolute minimum required to build a package. There are just a few files and folders created in the above process. Note we could do all of this by hand as well. We are using RStudio as our working environment, so let’s first create a new Project called “demoPackage”.

Let’s build a bare-bones package from scratch, defining each section as we go. This section provides the briefest of introductions, but enough to get you started. It is a very complete guide to the mechanics of R-packages. A common companion to that is Hadley’s Writing R packages. This is the official guide, and R-package developers should absolutely refer back to this page for reference. The official documentation is Writing R Extensions. There are many excellent resources on how to create an R package. Define internal functions and know their benefits.Apply the build and check features to a package.Correctly define what licenses and disclaimers are needed for USGS software.Be familiar with different ways data can be included in packages.List the structural components of an R-package.This lesson provides definitions and examples of the structural components of an R-package, and the minimum setup requirements.
