knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(PFUWorkflow)
PFUWorkflow
is an R
package that provides functions to build
a database of primary-to-final-to-useful (PFU) energy conversion chain (ECC)
societal exergy analyses (SEA).
PFUWorkflow
makes use of the drake package.
PFUWorkflow
creates drake
workflows that ensure that "What gets done stays done,"
leading to analyses that are more reproducible and less prone to errors.
To get started, follow these steps:
R
project in a new folder or repository.R
directory inside the new folder.R
directory,
make a file called plan.R
that calls PFUWorkflow::get_plan()
like this:plan <- PFUWorkflow::get_plan(countries = c("GHA", "ZAF"), max_year = 2017, iea_data_path = "<<IEA extended energy balance path>>", country_concordance_path = "<<Country concordance path>>", phi_constants_path = "<<phi constants path>>", ceda_data_folder = "<<CEDA temperature data path>>", machine_data_path = "<<Machine data path>>", exemplar_table_path = "<<exemplar table path>>", fu_analysis_folder = "<<FU analysis folder>>", reports_source_folders = "<<Reports source folders>>", reports_dest_folder = "<<Reports output folder>>", pipeline_caches_folder = "<<Pipeline caches folder>>", pipeline_releases_folder = "<<Pipeline releases folder>>", release = FALSE)
where
countries
is the list of countries to be analyzed,max_year
is the latest year to be analyzed,<<IEA extended energy balance path>>
is the path to a .csv
file that contains
IEA extended energy balance data,<<phi constants path>>
is the path to an Excel file of constant values of phi (the exergy-to-energy ratio),<<CEDA temperature data path>>
is the path to CEDA cru_cy temperature data downloaded through CEDATools
,<<Machine data path>>
is the path to the Machine data excel files containing Eta.fu, Phi.u, and other data.<<exemplar table path>>
is the path to an exemplar table (see below),<<FU analysis folder>>
is the path to a folder containing final-to-useful analyses, <<Reports source folders>>
is a vector of paths to folders containing report sources (usually .Rmd
and .Rnw
files), <<Reports output folder>>
is the path to a folder for completed reports, <<Pipeline caches folder>>
is the path to a folder in which the pipeline cache is stored as a .zip file, and <<Pipeline releases folder>>
is the path to a folder in which releases of pipeline objects are stored.The plan
object is a data frame that provides a list of "targets"
and code that will generate the target,
in the order the targets will be completed.
plan
drake::vis_drake_graph(plan)
`drake::make(plan)
or drake::r_make(plan)
.
When drake
is installed, the Addins
menu contains the item Run a drake workflow,
which sources the plan.R
file and calls drake::r_make(plan)
.A list of targets can be found with PFUWorkflow::target_names
.
The meanings of the targets can be obtained with ?PFUWorkflow::target_names
.
To query the results of executing the plan, say drake::readd(<<target>>)
,
where <<target>>
is unquoted.
Alternatively,
drake::readd("<<target>>", character_only = TRUE)
for
a string <<target>>
.
Targets are computed by country.
Say PFUWorkflow::readd_by_country("<<target>>", "<<country>>")
to obtain the value of a target for a country or vector of countries.
Both <<target>>
and <<country>>
need to be strings (enclosed in ""
)
for PFUWorkflow::readd_by_country()
.
unlink(".drake", recursive=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.