This template demonstrates traceability of a drake plan as a sequence of execution steps.

First the setup chunk sets the path to the project root - to conviently work with reproducible file-paths in headless and rstudio modes.

knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())

This code sources the current projects files - packages required, functions required and the base drake plans.

pkgload::load_all()
#> ℹ Loading reproducibleFairTemplate
#> Loading required package: tidyverse
#> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
#> ✔ ggplot2 3.3.3     ✔ purrr   0.3.4
#> ✔ tibble  3.1.1     ✔ dplyr   1.0.6
#> ✔ tidyr   1.1.3     ✔ stringr 1.4.0
#> ✔ readr   1.4.0     ✔ forcats 0.5.1
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag()    masks stats::lag()
#> Loading required package: rmarkdown
#> Loading required package: knitr
#> Loading required package: magrittr
#> 
#> Attaching package: 'magrittr'
#> The following object is masked from 'package:purrr':
#> 
#>     set_names
#> The following object is masked from 'package:tidyr':
#> 
#>     extract
#source("R/packages.R")
#source("R/functions.R")
#source("R/plan.R")

The first line of the following chunk forces a re-run of the whole drake workflow - comment it to see, if drake validates the current step.

drake::clean()
drake::make(scenario_wrapper())
vis_drake_graph(scenario_wrapper())

Mandrake - limited

Mandrake allows us to annotate and advance the documentation of a drake graph.

lookup_cache <- mandrake::load_package_colspec("reproducibleFairTemplate")
cache <- drake::drake_cache()
plan_extracted <- scenario_wrapper() %>%
  mandrake::decorate_plan(cache=cache, 
                          lookup_cache = lookup_cache,
                          desc_colname = "desc")
my_config <- drake_config(plan_extracted)
graph_info <- drake_graph_info(
  my_config, 
  group = "cluster_id", 
  clusters = c("summ", "coef"), 
  build_times = "none",
  on_select_col = "desc")

graph <- render_drake_graph(
  graph_info,
  on_select = "embedHandler",
  ncol_legend = 4) %>% 
  mandrake::attach_dependencies()
graph

Buidling of the analytic package

This section considers the build steps involved in the development and extension of an analysis.

First - be sure to document your package using roxygen with the following chunk.

#devtools::document()
#renv::snapshot()

Version_control

In order to look into the git commit history from R - one can use the gert library to see what happened.