scaffold
Initialize and load the project environment
The primary entry point for working with Framework projects. Call this at the start of every notebook or script to set up your environment with all configured packages, functions, and settings.
Usage
scaffold(config_file = NULL)
Arguments
| Argument | Description |
|---|---|
config_file
|
Path to configuration file. If NULL (default), automatically discovers settings.yml or config.yml in the project. |
Details
scaffold() performs the following steps in order:
- Standardizes working directory - Finds and sets the project root, even when called from notebooks in subdirectories
- Loads environment variables - Reads secrets from
.envfile - Loads configuration - Parses settings.yml for project settings
- Sets random seed - For reproducibility (if
seedis configured) - Installs packages - Any missing packages from the
packageslist - Loads packages - Attaches all configured packages
- Sources functions - Loads all
.Rfiles fromfunctions/directory
After scaffold() completes, you have access to:
- All packages listed in settings.yml
- All functions from your
functions/directory - Database connections configured in your project
Returns
Invisibly returns NULL. The main effects are side effects: loading packages and sourcing functions.
Project Discovery
When called without arguments, scaffold() searches for a Framework project by:
- Looking for settings.yml or config.yml in current and parent directories
- Checking for .Rproj or .code-workspace files with nearby settings
- Recognizing common Framework subdirectories (notebooks/, scripts/, etc.)
This means you can call scaffold() from any subdirectory within your project.
Configuration
The settings.yml file controls what scaffold() loads. Key settings include:
packages: List of R packages to install and loadseed: Random seed for reproducibilitydirectories: Custom directory pathsconnections: Database connection configurations
Examples
# At the top of every notebook or script:
library(framework)
scaffold()
# Now you can use your configured packages and functions
# Access settings via the settings object:
settings("directories.notebooks")
settings("seed")
See Also
Source: R/scaffold.R