General Development Workflow

General Development Workflow

Interactive development of new functions and reports is easy using devtools. Any R code (functions etc) go in the R folder of the package root. A good convention to follow is to have one file per function, however if you have a collection of related functions it may be best to keep them together. Please see later on how to document and test your functions. The latest code can be loaded into the R session (as if you had built, installed, and attached the package) by using the devtools::load_all() function. A useful shortcut for this inside RStudio is ctlr+shift+L.

Here’s an example workflow for adding a function to the package step by step

  1. Create function_name.R script in the R directory
  2. Write function code
  3. Load package with ctlr+shift+L
  4. Test function by calling it in the R session
  5. Fix bugs etc
  6. Document function (see later for details)
  7. Build tests for function (see later for details)

Once you are happy with your addition to the package you can build a source version for others to install and use with the following function.

devtools::build()

If you are are adding or modifying a vignette (built in report) then make sure you build with the following argument

devtools::build(vignettes = TRUE)

The vignettes are slow to build so I suggest only running them when you are working on the vignettes.