Learn R Programming

nprcgenekeepr (version 3.0.0)

appendColonySnapshot: Append a colony snapshot to a snapshot history

Description

Pure merge for the longitudinal colony snapshot workflow (issue #167): takes a validated snapshot history (or NULL / a zero-row history for a first snapshot) and one new snapshot row, and returns the merged, date-ordered history. It writes nothing — script users persist the result themselves (e.g. write.csv(..., row.names = FALSE)), and the Shiny application writes only through a user-initiated download.

Usage

appendColonySnapshot(history, snapshot)

Value

The merged history, ordered by snapshotDate.

Arguments

history

validated snapshot history data.frame (see checkSnapshotHistory), or NULL / a zero-row history when recording the first snapshot.

snapshot

one-row data.frame holding the new snapshot, in the same schema as the history. The row count and columns are not checked; rows are bound to the history as given.

Details

The new snapshot must carry the same schemaVersion as the history, and its (snapshotDate, membershipRule) pair must not already be present — the pair identifies a snapshot uniquely. The same date under a different membership rule is legal.

Examples

Run this code
history <- checkSnapshotHistory(readSnapshotHistory(system.file(
  "extdata", "examples", "example_snapshot_history.csv",
  package = "nprcgenekeepr"
)))
snapshot <- history[3L, ]
snapshot$snapshotDate <- as.Date("2026-07-15")
appendColonySnapshot(history, snapshot)

Run the code above in your browser using DataLab