This sets up simple folder structure and template files for an analysis project.

setup_analysis_project(
  folder = here::here(),
  analyses = c("data_prep", "analyses", "presentation"),
  pipeline_name = "outputs",
  code_folder = FALSE,
  standard_packages = c("magrittr", "here", "dplyr"),
  github_packages = NULL
)

Source

The structure is based on https://towardsdatascience.com/how-to-keep-your-research-projects-organized-part-1-folder-structure-10bd56034d3a, with some simplifications and additions.

Arguments

folder

Root folder of the project to be set up. Defaults to here::here()

analyses

Character vector of analysis steps. R files will be set up in order.

pipeline_name

Name of folder for outputs from each analysis step

code_folder

Logical. Should code files be placed in /code sub-folder? Otherwise, are placed in root folder

standard_packages

Character vector of packages to be loaded at start of each analysis file.

github_packages

Character vector of packages to be loaded and installed from Github if needed at start of each analysis file.

Details

The template includes two helpers worth highlighting. The take_note() function allows to add character strings to a note file that is saved at the end of each script. Usage should follow the first example: take_note("Note created:", timestamp(quiet = TRUE)). Note that this modifies notes in place, so the result should not be assigned.

Then there is the 0_run_all.R file, which runs all analysis scripts in order and documents when this last happened.