R Code Template
The lab R code template provides a starting structure with metadata, package loading, command-line arguments, validation, logging, processing, output generation, and session information. Adapt its behavior to the project and verify it with synthetic fixtures before use.
The example requires optparse and readr. It checks for missing packages and stops with setup instructions; it does not install packages during analysis. Prepare the environment using the optional R setup or restore an existing project lockfile with renv. Adjust the declared dependencies when adapting the template.
flowchart TB
accTitle: R code template sections
accDescr: A top-to-bottom workflow matching the physical order of major sections in the reusable R script template.
A[Metadata and usage] --> B[Library management]
B --> C[Command-line options]
C --> D[Parameter validation]
D --> E[Data loading]
E --> F[Processing and analysis]
F --> G[Output generation]
G --> H[Session information]