verify_IEATable_energy_balance: Confirm that an IEA-style data frame conserves energy.

View source: R/energy_balance.R

verify_IEATable_energy_balanceR Documentation

Confirm that an IEA-style data frame conserves energy.

Description

Energy balances are confirmed (within tol) for every combination of grouping variables in .ieatidydata.

Usage

verify_IEATable_energy_balance(
  .ieatidydata,
  ledger.side = "Ledger.side",
  energy = "E.dot",
  supply = "Supply",
  consumption = "Consumption",
  err = ".err",
  tol = 1e-06
)

Arguments

.ieatidydata

an IEA-style data frame containing grouping columns (typically Country, Year, Product, and others), a Ledger.side column, and an energy column (E.ktoe). .ieatidydata should be grouped prior to sending to this function.

ledger.side

the name of the column in .ieatidydata that contains ledger side information (a string). Default is "Ledger.side".

energy

the name of the column in .ieatidydata that contains energy data (a string). Default is "E.ktoe".

supply

the identifier for supply data in the ledger.side column (a string). Default is "Supply".

consumption

the identifier for consumption data in the ledger.side column (a string). Default is "Consumption".

err

the name of the error column in the output. Default is ".err".

tol

the maximum amount by which Supply and Consumption can be out of balance

Details

Be sure to group .ieatidydata prior to calling this function, as shown in the example.

If energy is in balance for every group, a data frame with additional column err is returned. If energy balance is not observed for one or more of the groups, a warning is emitted.

Value

a data frame containing with grouping variables and an additional column whose name is the value of err. The err column should be 0.

Examples

library(dplyr)
UKEnergy2000tidy %>%
  filter(Last.stage %in% c("Final", "Useful")) %>%
  group_by(Country, Year, Energy.type, Last.stage) %>%
  verify_IEATable_energy_balance(energy = "E.dot")

MatthewHeun/Recca documentation built on Feb. 9, 2024, 6:18 p.m.