Load an object from disk (format auto-detected; optional integrity checks)
Source:R/IO_core.R
st_load.RdLoad an object from disk (format auto-detected; optional integrity checks)
Arguments
- file
path or st_path. Can be:
A bare filename (e.g.,
"data.qs2") → loaded from<alias_root>/data.qs2/data.qs2A path with directory (e.g.,
"results/model.rds") → loaded from<alias_root>/results/model.rds/model.rdsWhen using a path with directory and an explicitalias, the alias root must be a parent of the path, otherwise an error is raised.
- format
optional format override
- version
An integer or a quoted directive. Retrieve a specific version of an artifact. See details.
- verbose
logical; if FALSE, suppress informational messages and package-generated warnings (default TRUE). When
FALSE, warnings about file/content hash mismatches and a missing primary key recorded byst_load()will not be shown.- alias
Optional stamp alias to target a specific stamp folder. If
NULL(default), uses the default alias. If the default alias does not exist, an error is raised. Use aliases to operate across multiple stamp folders.- ...
forwarded to format reader
Details
The version argument allows you to load specific versions:
NULL(default): loads the most recent version available.Negative integer (e.g.,
-1) or zero (0): loads that number of versions before the most recent version. So, if0, it loads the current version, which is equivalent toNULL. If-1, it will load the version right before the current one,-2loads two versions before, and so on.Positive numbers: Error.
Character: treated as a specific version ID (e.g., "20250801T162739Z-d86e8").
Interactive selection (e.g.,
"select","pick","choose") is supported and only non-interactive sessions must pass a concrete version id or negative integer for relative selection.
Examples
if (FALSE) { # \dontrun{
# Basic usage: load latest version
data <- st_load("data/mydata.rds")
# Load previous version
old_data <- st_load("data/mydata.rds", version = -1)
# Load specific version by ID
vid <- st_versions("data/mydata.rds")$version_id[3]
specific <- st_load("data/mydata.rds", version = vid)
# Interactive menu (in interactive sessions only)
# Interactive selection is not supported in non-interactive contexts.
# Pass explicit version id or a negative integer.
} # }