Skip to contents

Save an R object to disk with metadata & versioning (atomic move)

Usage

st_save(
  x,
  file,
  format = NULL,
  metadata = list(),
  code = NULL,
  parents = NULL,
  code_label = NULL,
  pk = NULL,
  domain = NULL,
  unique = TRUE,
  verbose = TRUE,
  alias = NULL,
  ...
)

Arguments

x

object to save

file

destination path (character or st_path). Can be:

  • A bare filename (e.g., "data.qs2") → saved to <alias_root>/data.qs2/data.qs2

  • A path with directory (e.g., "results/model.rds") → saved to <alias_root>/results/model.rds/model.rds When using a path with directory and an explicit alias, the alias root must be a parent of the path, otherwise an error is raised.

format

optional format override ("qs2" | "rds" | "csv" | "fst" | "json")

metadata

named list of extra metadata (merged into sidecar)

code

Optional function/expression/character whose hash is stored as code_hash.

parents

Optional list of parent descriptors: list(list(path = "", version_id = ""), ...).

code_label

Optional short label/description of the producing code (for humans).

pk

optional character vector of primary-key columns (for tables)

domain

optional character scalar or vector label(s) for the dataset

unique

logical; enforce uniqueness of pk at save time (default TRUE)

verbose

logical; if FALSE, suppress informational messages and package-generated warnings (default TRUE). When FALSE, messages about skipped saves or save failures emitted by st_save() 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 writer

Value

invisibly, a list with path, metadata, and version_id (or skipped=TRUE)