
Validate econanalyzr tibble structure
Source:R/utils-check_econanalyzr_df.R
check_econanalyzr_df.Rd
Enforces the econanalyzr schema:
First 9 required columns with exact names and expected low-level type & primary class:
date (Date/double)
,date_period_text (character)
,value (numeric/double)
,data_element_text (character)
,data_measure_text (character)
,date_measure_text (character)
,data_transform_text (character)
,geo_entity_type_text (character)
,geo_entity_text (character)
.Any number of optional columns may appear after the first 9.
The final column must be
viz_type_text
of type/classcharacter
.
Details
If all required columns and viz_type_text
are present but out of order, the function
emits a warning and reorders the columns to: required 9 (in order) → optional(s) → viz_type_text
.
Special handling of date
:
Accepts base
Date
and subclasses. Subclasses are coerced to plainDate
with a warning.Accepts
zoo::yearmon
/zoo::yearqtr
(ifzoo
is installed) and always coerces toDate
at the start of the period (first day of the month/quarter) with a warning.Accepts
POSIXct
/POSIXlt
and coerces toDate
(drop time) usingdatetime_tz
.
Special handling of value
:
Must be double; if numeric but not double (e.g., integer or other numeric class), the column is coerced to double with a warning. Non-numeric is an error.
To support yearmon
/yearqtr
, add zoo
to Suggests. If a yearmon
/yearqtr
column is
encountered and zoo
is not installed, a classed error is raised with guidance.