Skip to contents

Adds any missing canonical columns as NAs of the right type and reorders canonical columns first. Extra user-supplied columns are preserved at the end. Coerces character values to numeric where the schema requires it.

Usage

ensure_horizon_schema(h)

Arguments

h

Input data.frame or data.table.

Value

A data.table with the canonical horizon columns present, in canonical order, with extra columns preserved at the end.

Examples

h <- ensure_horizon_schema(data.frame(top_cm = 0, bottom_cm = 20))
"designation" %in% names(h)
#> [1] TRUE