Learn R Programming

chronicler (version 0.3.0)

zap_log: Zap the log of a chronicle object

Description

This function replaces the entire existing log of a chronicle object with a single, new entry. This new entry simply records that the log was "zapped" and the time at which it occurred.

This is useful for simplifying a chronicle object before saving or sharing, or to mark a definitive checkpoint in a workflow, effectively discarding the previous history. The underlying value of the object remains completely unchanged.

Usage

zap_log(.c)

Value

A new chronicle object with the same value as the input, but with its log_df replaced by a single entry.

Arguments

.c

A chronicle object.

Examples

Run this code
library(dplyr)

# 1. Create a chronicle object with a multi-step log
r_select <- record(select)
r_filter <- record(filter)

original_chronicle <- starwars %>%
  r_select(name, height, mass, species) %>%
  bind_record(r_filter, species == "Human")

# 2. View the original, detailed log
cat("--- Original Log ---\n")
read_log(original_chronicle)

# 3. Zap the log
zapped_chronicle <- zap_log(original_chronicle)

# 4. View the new, simplified log
cat("\n--- Zapped Log ---\n")
read_log(zapped_chronicle)

# 5. The underlying data value is unaffected
identical(
  unveil(original_chronicle, "value"),
  unveil(zapped_chronicle, "value")
)

Run the code above in your browser using DataLab