An opinionated lightweight template for smooth drake
flows.
remotes::install_github("milesmcbain/dflow")
Set dependencies = TRUE
to also install capsule, conflicted, dontenv, and drake.
dflow::use_dflow()
:
./
|_ R/
| |_ plan.R
|
|_ _drake.R
|_ packages.R
|_ .env
dflow::use_rmd("analysis.Rmd")
:
v Creating 'doc/'
v Writing 'doc/analysis.Rmd'
Add this target to your drake plan:
target_name = target(
command = {
rmarkdown::render(knitr_in("doc/analysis.Rmd")),
file_out("doc/analysis.html")
}
)
(change output extension as appropriate if output is not html)
library(rmarkdown) added to ./packages.R
dflow::use_gitignore()
:
Drop in a starter ./.gitignore
with ignores for drake
and renv
among others.
dflow
tries to set up a minimalist ergonomic workflow for drake
pipeline
development. To get the most out of it follow these tips:
-
Put all your target code in separate functions in
R/
. Usefnmate
to quickly generate function definitions in the right place. Letplan.R
define the structure of the workflow and use it as a map for your sources. Use 'jump to function' to quickly navigate to them. -
Use a call r_make() to kick off building your plan in a new R session (via
callr
)._drake.R
is setup to make this work. Bind a keyboard shortcut to this using the addin in drake. -
Put all your
library()
calls intopackages.R
. This way you'll have them in one place when you go to add sandboxing withrenv
,packarat
, andswitchr
etc. -
Take advantage of automation for loading drake targets at the cursor with the 'loadd target at cursor' addin.
Some things are baked into the template that will help you avoid common pitfalls and make your project more reproducible:
-
library(conflicted)
is called inpackages.R
to detect package masking issues. -
.env
is added carrying the following options to avoid misuse of logical vector tests:
_R_CHECK_LENGTH_1_LOGIC2_=verbose
_R_CHECK_LENGTH_1_CONDITION_=true