is_balanced: Tells whether IEA data are balanced

View source: R/data_functions.R

is_balancedR Documentation

Tells whether IEA data are balanced

Description

Performs the the energy balance check in a way that is amenable to drake subtargets. Internally, this function uses IEATools::calc_tidy_iea_df_balances(). Grouping is doing internal to this function using the value of grp_vars.

Usage

is_balanced(
  IEAData,
  countries,
  country = IEATools::iea_cols$country,
  grp_vars = c(country, IEATools::iea_cols$method, IEATools::iea_cols$energy_type,
    IEATools::iea_cols$last_stage, IEATools::iea_cols$year, IEATools::iea_cols$product)
)

Arguments

IEAData

a tidy IEA data frame

countries

the countries for which balancing should be checked as strings

country

The name of the country column in IEAData. Default is Country.

grp_vars

the groups that should be checked. Default is c(country, IEATools::iea_cols$method, IEATools::iea_cols$energy_type, IEATools::iea_cols$last_stage, IEATools::iea_cols$product).

Value

a logical stating whether all products are balanced for the country of interest

Examples

# These data are not balanced, because they are raw.
IEATools::sample_iea_data_path() %>%
  IEATools::load_tidy_iea_df() %>%
  is_balanced(countries = "ZAF")

MatthewHeun/SEAPSUTWorkflow documentation built on April 22, 2022, 2:21 p.m.