View source: R/lib_data_loader.R
| validate_schema | R Documentation |
Checks a raw data frame against the schema block of a provenance
object: required columns, row-count bounds, and allowed categorical
value sets. Returns the issues found rather than raising, so the caller
decides how to react.
validate_schema(df_raw, provenance)
df_raw |
The data frame to validate. |
provenance |
A provenance list as returned by |
A named list of issues; each issue is a list with severity
("fatal" or "warning") and a human-readable message. A
zero-length list means the data frame is clean.
prov <- list(schema = list(
expected_columns = c("id", "year"),
structural_invariants = list(min_data_rows = 1),
expected_value_sets = list(year = 2020:2025)
))
df <- data.frame(id = 1:3, year = c(2020, 2021, 2030))
issues <- validate_schema(df, prov)
names(issues) # flags the out-of-set year value
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.