fu_allocation_table_completed: Tell whether a final-to-useful allocation table has been...

View source: R/tables.R

fu_allocation_table_completedR Documentation

Tell whether a final-to-useful allocation table has been completed

Description

A final-to-useful allocation table is complete iff all of the final energy flows for a country are routed to a final-to-useful machine for each year in which those final energy flows exist. Also, all routes need to add to 100%, within .tol. If not, an error is thrown.

Usage

fu_allocation_table_completed(
  fu_allocation_table = NULL,
  specified_iea_data,
  country = IEATools::iea_cols$country,
  year = IEATools::iea_cols$year,
  ledger_side = IEATools::iea_cols$ledger_side,
  e_dot = IEATools::iea_cols$e_dot,
  unit = IEATools::iea_cols$unit,
  flow = IEATools::iea_cols$flow,
  product = IEATools::iea_cols$product,
  flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
  consumption = IEATools::ledger_sides$consumption,
  eiou = IEATools::tfc_compare_flows$energy_industry_own_use,
  maximum_values = IEATools::template_cols$maximum_values,
  quantity = IEATools::template_cols$quantity,
  .values = IEATools::template_cols$.values,
  C_source = IEATools::template_cols$c_source,
  ef_product = IEATools::template_cols$ef_product,
  destination = IEATools::template_cols$destination,
  machine = IEATools::template_cols$machine,
  e_u_product = IEATools::template_cols$eu_product,
  e_dot_perc = IEATools::template_cols$e_dot_perc,
  .tol = 1e-09,
  .err = ".err"
)

Arguments

fu_allocation_table

The final-to-useful allocation table whose completeness is to be ascertained. If NULL (the default), all rows in specified_iea_data that need allocation are returned as the "unallocated_rows" attribute of FALSE.

specified_iea_data

An IEA data frame from which final energy flows are gleaned. This data frame should be generated by specify_all().

country, year, ledger_side, e_dot, unit, flow, product, flow_aggregation_point

See IEATools::iea_cols.

consumption

See IEATools::ledger_sides.

eiou

See IEATools::tfc_compare_flows.

maximum_values, quantity, .values, ef_product, destination, machine, e_u_product, e_dot_perc, C_source

See IEATools::template_cols.

.tol

The tolerance for error when checking if all allocations for a particular final energy flow sum to 1. Default is 1e-9. If allocations do not sum to 1, an error is emitted.

.err

A column of error terms indicating distance between the sum of C values for a given final energy flow and 1.

Details

This function should really be named ⁠fu_allocation_table_completed?⁠, because it answers a question.

Value

A boolean telling whether fu_allocation_table is complete. If FALSE, a data frame of IEA final energy rows that have not been allocated is stored in the "unallocated_rows" attribute of the return value. Retrieve with attr(done, "unallocated_rows") if the result of this function is assigned to the variable done.

Examples

iea_data <- load_tidy_iea_df() %>% 
  specify_all()
fu_allocations <- load_fu_allocation_data()
fu_allocation_table_completed(fu_allocations, iea_data)

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