This package provides the raw data, analysis code, and outputs as well as the computational environment needed to reproduce the project/compendium “drakepkg”. The project uses the R package drake to define a reproducible processing pipeline linking inputs to outputs/targets similar to GNU make (for more information on the drake package, see here). This vignette describes how to reproduce the analysis, check the analysis pipeline, and inspect analysis steps and outputs.

Copy the analysis directory structure

After attaching the package, executing the function copy_analysis() copies the analysis directory structure to the current working directory (or an explicitely specified directory). The directory should now contain the following files:

.
└── analysis
    ├── data
    │   └── other-iris.xlsx
    ├── manuscript
    │   └── report.html
    └── templates
        └── report.Rmd

These files represent all input files required to reproduce the analysis as well as all output files generated in the process. The function further copies the .drake directory to the same directory. This hidden directory stores information about the consistency of the analysis pipeline and all intermediate outputs.

Reproduce the analysis

Reproducing the analysis can be done in a two-step procedure:

  1. Executing the function reproduce_analysis() copies the analysis directory structure (if it isn’t already present) and then runs drake::make(). The output provides evidence of reproducibility without actually re-running the analysis. If the analysis is reproducible, the output should look like this:
  1. To independently re-create the analysis results on ones own computer, one can run reproduce_analysis() with the option re_run = TRUE. This will delete the copied .drake folder and re-run the entire project from scratch, re-creating all relevant intermediate steps and outputs.

Explore the analysis pipeline and results

Executing get_plan() returns the underlying drake plan used to run the analysis. The returned tibble lists all intermediate results (targets), the commands executed to create them, and the dependencies between them.

The drake package provides several ways to visualize the project, e.g.

Furthermore, drake provides functions for viewing individual targets (drake::readd()) or load them into the current environment (drake::loadd()). For example, to view the cleaned data frame, use

or to view the figure included in the report, use

Cleaning up

Executing delete_analysis() removes the analysis and .drake directories from the working directory (or an explicitely specified directory).