Skip to contents

Runs every `eiod_check_*` function over a data frame and returns a single report. This is the function to call first, before [eiod_absolute_threshold()] or anything else.

Usage

eiod_check_data(
  data,
  impacts = NULL,
  age = NULL,
  sex = NULL,
  gdqs = NULL,
  age_units = c("years", "months"),
  male = NULL,
  female = NULL,
  tolerance = 1e-06
)

# S3 method for class 'eiod_check'
print(x, ...)

# S3 method for class 'eiod_check'
summary(object, ...)

Arguments

data

A data frame.

impacts

A named character vector mapping indicator names to column names, for example `c(biodiv = "biodiv_pdf", ghg = "ghg_kg")`. Names must be among the seven in [eiod_list_indicators()].

age, sex, gdqs

Column names, or `NULL` to skip that check.

age_units

`"years"` (default) or `"months"`.

male, female

Optional sex codes; see [eiod_age_sex_group()].

tolerance

Relative distance from a cut-off below which a classification is treated as not robust. Default `1e-6`.

x

An `eiod_check` object.

...

Ignored.

object

An `eiod_check` object.

Value

An object of class `eiod_check`. Use `summary()` for a single pass/fail, or treat it as a data frame to filter the findings.

What it checks

  • **Structure** - that each named column exists, and that impact columns are doubles rather than factors, characters or integers.

  • **Validity** - no negative or non-finite impacts, exact zeros flagged, missingness reported.

  • **Precision** - significant digits actually retained, and how many observations sit close enough to a cut-off that rounding could change their classification. See [eiod_check_precision()].

  • **Unit magnitude** - each impact compared against the published global reference, with likely unit errors named. See [eiod_check_magnitude()].

  • **Demographics** - age range and units, sex coding, coverage of the eight groups, and the count of under-twos.

  • **GDQS** - type and range.

Severity

`error` means a metric computed on this data would be wrong, not merely uncertain; fix it first. `warning` means proceed, but you need to have looked. `note` is information worth having in the record.

See also

[eiod_check_impact()], [eiod_check_precision()], [eiod_check_magnitude()], [eiod_check_demographics()], [eiod_check_gdqs()]

Examples

data(eiod_demo)

report <- eiod_check_data(
  eiod_demo,
  impacts = c(biodiv = "biodiv_pdf", ghg = "ghg_kgco2e"),
  age = "age", sex = "sex", gdqs = "gdqs"
)
report
#> reiod data quality report
#>   data: eiod_demo   n = 600
#> 
#>   ERROR    0
#>   WARNING  0
#>   NOTE     13
#> 
#>   NOTE     sex            sex          sex is a factor with levels "male", "female". This is the recommended
#>                                        input type.
#>   NOTE     group          coverage     15 respondent(s) under 2 years. Tables 3 and 4 apply to them; HESD and
#>                                        HDLEI do not, and will be NA. Decide explicitly whether they belong in
#>                                        your denominator.
#>   NOTE     biodiv_pdf     missing      12 missing (2.0%). These return NA, not 0.
#>   NOTE     biodiv_pdf     unit         expected unit for "biodiv": PDF*year per capita per day.
#>   NOTE     biodiv_pdf     precision    up to 17 significant digits retained across 588 distinct values.
#>   NOTE     biodiv_pdf     proximity    no observation sits within 1e-06 of the absolute threshold, so stored
#>                                        precision does not change any classification here.
#>   NOTE     biodiv_pdf     magnitude    median 8.317e-13 vs expected 7.602e-13 for this demographic mix (ratio
#>                                        1.09).
#>   NOTE     ghg_kgco2e     unit         expected unit for "ghg": kg CO2eq per capita per day.
#>   NOTE     ghg_kgco2e     precision    up to 17 significant digits retained across 600 distinct values.
#>   NOTE     ghg_kgco2e     proximity    no observation sits within 1e-06 of the absolute threshold, so stored
#>                                        precision does not change any classification here.
#>   NOTE     ghg_kgco2e     magnitude    median 3.061 vs expected 5.547 for this demographic mix (ratio 0.552).
#>   NOTE     gdqs           missing      8 missing (1.3%); HESD and HDLEI will be NA for these.
#>   NOTE     gdqs           range        range 12.1 to 37.9; 59.1% at or above the cutoff of 23.
#> 
#>   No blocking problems.
summary(report)
#> PASS - 0 error, 0 warning, 13 note