Skip to contents

Structural and plausibility checks on one impact vector: storage type, sign, zeros, missingness and non-finite values.

Usage

eiod_check_impact(value, name = "impact", indicator = NULL)

Arguments

value

The impact vector to check. May be any type; that is the point.

name

A label for the variable, used in the report.

indicator

Optionally the indicator name, used to report the expected unit.

Value

An object of class `eiod_check`.

Why the type checks are errors

Three import failures destroy impact data silently, and all three are common with the very small values biodiversity loss takes:

  • A **factor** column. `as.numeric()` on a factor returns the level codes, so `3.7e-13` becomes `1`. A plausible-looking number with no warning is far worse than `NA`, because nothing downstream looks wrong.

  • A **character** column, usually caused by one stray cell such as `"<0.001"` or a decimal comma. Coercion then yields `NA` with a warning that is easy to miss.

  • An **integer** column. It cannot represent `1e-13` at all; the value is already `0` by the time you see it.

Examples

data(eiod_demo)
eiod_check_impact(eiod_demo$biodiv_pdf, name = "biodiv_pdf")
#> reiod data quality report
#> 
#>   ERROR    0
#>   WARNING  0
#>   NOTE     1
#> 
#>   NOTE     biodiv_pdf     missing      12 missing (2.0%). These return NA, not 0.
#> 
#>   No blocking problems.

# a factor column, the worst of the three import failures
eiod_check_impact(factor(c("3.7e-13", "5.2e-13")), name = "biodiv")
#> reiod data quality report
#> 
#>   ERROR    1
#>   WARNING  0
#>   NOTE     0
#> 
#>   ERROR    biodiv         type         column is a factor. as.numeric() on a factor returns level codes, not
#>                                        values, so this fails silently. Fix with as.numeric(as.character(x)).
#> 
#>   1 blocking problem. Fix before computing metrics.