check_fu_allocation_data: Check validity of a final-to-useful allocation table

View source: R/templates.R

check_fu_allocation_dataR Documentation

Check validity of a final-to-useful allocation table

Description

When analysts fill final-to-useful allocation templates created with fu_allocation_template(), some errors are likely. This function checks for typical errors and emits helpful error messages that point the analyst to the location of the problem.

Usage

check_fu_allocation_data(
  .fu_allocation_table,
  country = IEATools::iea_cols$country,
  year = IEATools::iea_cols$year,
  flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
  machine = IEATools::template_cols$machine,
  ef_product = IEATools::template_cols$ef_product,
  eu_product = IEATools::template_cols$eu_product,
  destination = IEATools::template_cols$destination,
  quantity = IEATools::template_cols$quantity,
  .values = IEATools::template_cols$.values,
  non_energy_machine = "Non-energy"
)

Arguments

.fu_allocation_table

The final-to-useful allocation table you want to check.

country, year, flow_aggregation_point

See IEATools::iea_cols.

machine, ef_product, eu_product, destination, quantity, .values

See IEATools::template_cols.

non_energy_machine

The string that identifies a Non-energy machine. Default is "Non-energy".

Details

This function checks for two typical errors.

  • First, this function checks that ef_product and eu_product are identical when machine is non_energy_machine.

  • Second, this function checks that machine and eu_product are present when .values is not NA. This check is performed on a tidy version of .fu_allocation_table.

Value

TRUE if the checks are successful. An error is emitted if the checks fail.

Examples

load_fu_allocation_data() %>% 
  check_fu_allocation_data()

MatthewHeun/IEATools documentation built on Feb. 6, 2024, 3:29 p.m.