settings
Get settings value by dot-notation key
Framework's primary configuration helper that supports both flat and hierarchical key access using dot notation. Automatically checks common locations for directory settings. Pretty-prints nested structures in interactive sessions.
Usage
settings(key = NULL, default = NULL, settings_file = NULL)
Arguments
| Argument | Description |
|---|---|
key
|
Character. Dot-notation key path (e.g., "notebooks" or "directories.notebooks" or "connections.db.host"). If NULL, returns entire settings. |
default
|
Optional default value if key is not found (default: NULL) |
settings_file
|
Settings file path (default: checks "settings.yml" then "settings.yml") |
Details
For directory settings, the function checks multiple locations:
- Direct:
settings("notebooks")checksdirectories$notebooks, thenoptions$notebook_dir - Explicit:
settings("directories.notebooks")checks onlydirectories$notebooks
File Discovery:
- Checks
settings.ymlfirst (Framework's preferred convention) - Falls back to
settings.ymlif settings.yml not found - You can override with explicit
settings_fileparameter
Output Behavior:
- Interactive sessions: Pretty-prints nested lists/structures and returns invisibly
- Non-interactive (scripts): Returns raw value without printing
- Simple values: Always returned directly without modification
Returns
The settings value, or default if not found. In interactive sessions, nested structures are pretty-printed and returned invisibly.
Examples
# Get notebook directory (checks both locations)
settings("notebooks")
# Get explicit nested setting
settings("directories.notebooks")
settings("connections.db.host")
# Get entire section
settings("directories") # Returns all directory settings
settings("connections") # Returns all connection settings
# View entire settings
settings() # Returns full configuration
# With default value
settings("missing_key", default = "fallback")
Source: R/config.R