Learn R Programming

keyed (version 0.2.0)

stamp: Stamp a data frame as reference

Description

Stores a snapshot of the current data state, including the full data frame. This enables cell-level drift reports when used with check_drift().

Usage

stamp(.data, name = NULL, .silent = FALSE)

commit_keyed(.data, name = NULL)

Value

Invisibly returns .data with snapshot metadata attached.

Arguments

.data

A data frame (preferably keyed).

name

Optional name for the snapshot. If NULL, derived from data.

.silent

If TRUE, suppress cli output. Used internally by auto-stamping in watch()ed data frames.

Details

Snapshots are stored in memory for the session. They are keyed by content hash, so identical data shares the same snapshot.

When data is watch()ed, dplyr verbs auto-stamp before executing, creating an automatic safety net for drift detection.

See Also

watch() for automatic stamping before dplyr verbs.

Examples

Run this code
df <- key(data.frame(id = 1:3, x = c("a", "b", "c")), id)
df <- stamp(df)

# Later, check for drift
df2 <- df
df2$x[1] <- "z"
check_drift(df2)

Run the code above in your browser using DataLab