
Validate a shinyplanr feature dictionary (Dict_Feature.csv)
Source:R/validate_config.R
validate_dict.RdRuns structural checks on the raw (unfiltered) feature dictionary read from
Dict_Feature.csv in setup/3_setup_app.R, before the
includeApp filter is applied. Call this immediately after
readr::read_csv() and before dplyr::filter(includeApp).
Arguments
- Dict
A data frame. The raw (unfiltered) feature dictionary, typically the direct output of
readr::read_csv(file.path(setup_dir, "Dict_Feature.csv")).- strict
Logical. If
TRUE(default), stops immediately with a clear, actionable error message on the first failed check. IfFALSE, all checks are run and a summary report is returned invisibly;warning()is called for each failure.
Value
When strict = FALSE, invisibly returns a named list of
logical values (TRUE = passed, FALSE = failed) for each
check. When strict = TRUE, returns invisible(TRUE) if all
checks pass.
Details
Catching problems here – before the data is loaded – gives the deployer the clearest possible error messages, because the issue is in the CSV they just edited rather than buried inside a spatial data pipeline.
Checks performed
All required columns are present in
Dict.includeAppandincludeJustcolumns are logical (TRUE/FALSE), not character or integer. A common mistake is editing the CSV in Excel, which can convertTRUEto1or"TRUE"(character), causingdplyr::filter(includeApp)to silently drop all rows.All values in the
typecolumn are from the known set ("Feature","Cost","LockIn","LockOut","Bioregion","EcosystemServices","Justification"). A typo like"feature"(lowercase) silently excludes a row from all app processing.nameVariableis unique within eachtype. Duplicates cause silent bugs inprioritizr(duplicate feature columns) and duplicate slider input IDs in the Shiny UI. Note: the samenameVariablemay legitimately appear in both"LockIn"and"LockOut"rows (e.g. MPAs) – uniqueness is only enforced within each type.At least one row has
includeApp == TRUEandtype == "Feature". An app with no active features cannot run a prioritisation.All rows with
includeApp == TRUEandtype == "Feature"havetargetMin,targetMax, andtargetInitialvalues in the 0–100 range. Out-of-range values causeprioritizrto error at solve time.