Checks a constraint table for common errors.
check_constraint(constraint_var, num_zones)
constraint_var | The constraint table to check, usually a data frame |
---|---|
num_zones | The number of zones that should be present in the table |
If no errors are detected the function returns silently. Any errors will stop the function or script to be investigated.
Checks a constraint table for the following common errors:
Ensures all zone codes are unique
Ensures there are the expected number of zones
Ensures all but the zone column are numeric (integer or double)
cons <- data.frame( "zone" = letters[1:3], "age_0_49" = c(8, 2, 7), "age_gt_50" = c(4, 8, 4), "sex_f" = c(6, 6, 8), "sex_m" = c(6, 4, 3) ) check_constraint(cons, 3) # no errors