B.2 Directory and File Structure

The key files and folders of the Air Health SWS targets pipeline are as follows:

├── main.R
├── _targets.R
├── renv.lock
├── R/
├──── func_analysis/
├──── func_data/
├──── func_helpers/
├──── func_viz/
├──── import_data/
├──── pipelines/
├── renv/

The main.R script is where you should start. It contains a few lines of code for restoring the packages, visualising the targets pipeline, running the pipeline and viewing target results. It does not make any changes to the workflow. Further exploratory analysis, outside of the pipeline, can be added here.

The file renv.lock and folder renv/ are part of renv, a package management library. Opening the R project should automatically prompt renv to install and activate the project environment. Running renv::restore() will install required packages (as according to renv.lock).

The _targets.R script forms the essential core of the targets pipeline, This is where the targets are defined, along with sourcing of required functions and specification of required libraries. See Section B.3 for more information.

All custom functions are stored in the R/ folder. These are sourced near the top of the _targets.R script (and in main.R where needed). For clarity, the functions are arranged in a series of folders:

  • func_analysis/: functions to analyse input data, acting on tidied and combined data
  • func_data/: functions to combine and derive tidied input data to prepare for analysis
  • func_helpers/: miscellaneous helper functions that are not directly concerned with the processing or analysis of data
  • func_viz/: functions to visualise or output data
  • import_data/: functions to create targets for the import and tidying of specific datasets
  • pipelines/: examples of metaprogramming in targets package (not implemented)