Skip to contents

Ten ingests "register" their types by deleting the existing row and binding a freshly-built literal in its place:

Usage

upsert_measurement_types(
  d,
  new_types,
  preserve = c("valid_min", "valid_max", "valid_depth_min_m", "valid_depth_max_m")
)

Arguments

d

the current registry (a data.frame, e.g. from read_measurement_type())

new_types

data.frame of definitions to upsert; needs measurement_type

preserve

columns to carry forward from the existing row when new_types does not supply a non-NA value. Defaults to the bound columns — the ones an ingest never authors and a provider has agreed.

Value

The updated registry, sorted by measurement_type.

Details

d_meas_type |> filter(measurement_type != "euphausiid_abundance") |>
  bind_rows(euph_types)          # <- literal, no valid_min/valid_max

Every column the literal omits is destroyed on each re-run. That is how a provider-agreed valid_min silently disappeared from euphausiid_abundance and the four picoplankton types during the v2026.08.08 re-render: the ingests had not changed, but a curated column had been added underneath them. Only ingest_calcofi_mets.qmd did the preserve-and-merge dance by hand.

Use this instead of filter(... != x) |> bind_rows(new). It replaces the definition columns the ingest owns and carries the curated ones forward from the row being replaced, so a re-run cannot quietly narrow the registry.

See also

declare_measurement_bounds() to set a bound, register_measurement_types() to append a genuinely new type.

Examples

if (FALSE) { # \dontrun{
d_meas_type <- upsert_measurement_types(d_meas_type, euph_types)
readr::write_csv(d_meas_type, meas_type_csv, na = "")
} # }