knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
drakeme()
: Quickly jump into a drake workflowflowme::drakeme()
flowme::drakeme()
includes our boilerplate code for drake
-powered projects
in your current session. It is originally based on McBain's
dflow
and it is tailored to our
report-generating projects.
We put together this template, mainly, to:
These are the key features to achieve those aims (admittedly, some could be highly controversial. Yet, they work for us).
Fully functional drake
project at the push of a button: once installed,
flowme
helps you setup a drake project with one-function call
(flowme::drakeme()
), including all required packages.
It will get you started with a "hello world" project that you can actually
run (drake::r_make()
) and see the output. A1
devtools::load_all()
friendly: flowme::drakeme()
makes sure your
project has a DESCRIPTION file, and if you have devtools
installed,
devtools::load_all()
would just work (you may need to restart RStudio for
the keyboard shortcut to work). By placing 0_packages.R
within R directory,
packages will also be loaded/attached.
A bookdown
-based report/book in the flow: flowme::drakeme()
sets the
stage for the project to produce a report with bookdown
. You simply add
Rmd
files to the "report" folder and you are good to go. This is achieved by
including a target at the end of the plan to render all Rmd
files in the
report
directory into a single book. Thus, you do not have to include one
target for each Rmd
, but rather just work on your Rmd
and put them all
in the report
directory. Take a look at plan_bookme()
and bookme()
to
see how this is done.
Here's the file structure flowme::drakeme()
includes in your current project:
example_dir <- fs::dir_create(paste0(tempdir(), "/drake_example")) xfun::in_dir(example_dir, flowme::use_drake()) xfun::in_dir(example_dir, fs::dir_tree(all = TRUE))
+-- .gitignore +-- .Rbuildignore +-- DESCRIPTION +-- R | +-- 0_packages.R | +-- drakeme.R | +-- plan_bookme.R | \-- plan_sessioninfo.R +-- report | +-- chapter1.Rmd | +-- _bookdown.yml | +-- _output.yml | \-- _style.docx \-- _drake.R
the_plan
) should be defined in _drake.R
,
by binding together sub-plans. So no details on the processing here (unless
it is a really simple project, in which case you probably do not need drake
anyway, so, please just don't). Hence, the plan should look something like
the example below, which makes it easy for a newcomer to quickly know what
the project is all about.``` r the_plan <- drake::bind_plans(
plan_network_analysis(), plan_survey_analysis(), plan_financial_analysis(), plan_bookme() # Just render the report using bookdown
) ```
Define sub-plans within functions that return a drake::drake_plan
.
Defining the plans within functions instead of directly as objects helps
navigating the project. You look at the plan, put the cursor on the sub-plan
you want to go to and hit F2.
Include Rmd
in the report
directory, using the targets in the plans by
calling drake::loadd
or drake::readd
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.