arrange_iea_fu_allocation_template: Arrange the rows and/or columns of a final-to-useful...

View source: R/templates.R

arrange_iea_fu_allocation_templateR Documentation

Arrange the rows and/or columns of a final-to-useful allocation template

Description

It is helpful to sort rows and columns of a final-to-useful allocation template in reasonable ways to assist analysts. This function sorts rows (top-to-bottom) by default in the same order as appears in the IEA extended energy balance data. Other orderings can be specified with the fap_flow_order and ef_product_order arguments. It sorts columns (left-to-right) in the order of energy flow through the energy conversion chain.

Usage

arrange_iea_fu_allocation_template(
  .fu_allocation_template,
  rowcol = c("both", "row", "col"),
  ledger_side = "Ledger.side",
  flow_aggregation_point = "Flow.aggregation.point",
  ef_product = "Ef.product",
  machine = "Machine",
  eu_product = "Eu.product",
  destination = "Destination",
  unit = "Unit",
  fap_dest_order = IEATools::fap_flows,
  ef_product_order = IEATools::products,
  quantity = "Quantity",
  maximum_values = "Maximum.values",
  .temp_sort = ".fap_flow",
  .clean_ef_product = ".clean_Ef_product"
)

Arguments

.fu_allocation_template

the final-to-useful allocation template created by fu_allocation_template()

rowcol

one of "both", "row", or "col" to indicate whether rows, columns, or both should be arranged. Default is "both".

ledger_side

the ledger side column in .fu_allocation_template. Default is "Ledger.side".

flow_aggregation_point

the flow aggregation point column in .fu_allocation_template. Default is "Flow.aggregation.point".

ef_product

the name of the final energy column in .fu_allocation_template. Default is "Ef.product".

machine

the name of the machine column in .fu_allocation_template. Default is "Machine".

eu_product

the name of the useful energy product column in .fu_allocation_template. Default is "Eu.product".

destination

the name of the destination column in .fu_allocation_template. Default is "Destination".

unit

the name of the unit in .fu_allocation_template. Default is "Unit".

fap_dest_order

the desired order for the combination of flow_aggregation_point and destination columns. Default is IEATools::fap_flow_iea_order.

ef_product_order

the desired order for final energy products in .fu_allocation_template. Default is "Ef.product".

quantity

the name of the quantity column in .fu_allocation_template. Default is "Quantity".

maximum_values

the name of the maximum value column .fu_allocation_template. Default is "Unit".

.temp_sort

the name of a temporary column to be added to .fu_allocation_template. Default is ".fap_flow". This column must not be present in .fu_allocation_template.

.clean_ef_product

the name of a temporary column to be added to .fu_allocation_template. Default is ".clean_ef_product". This column must not be present in .fu_allocation_template.

Details

When sorting rows, the flow_allocation_point, flow, and product columns are considered. Internally, this function figures out which columns are metadata columns and groups on those columns before applying the row ordering. If you want to preserve ordering by metadata, be sure to set factor levels on metadata columns prior to calling this function.

When sorting columns, the order of energy flows through the energy conversion chain is considered. The column order is:

  • metadata columns,

  • final energy product (Ef.product).

  • Machine (the final-to-useful transformation process),

  • useful energy product (Eu.product),

  • destination where the useful energy now flows,

  • years (in columns), and

  • allocations (C_x rows).

Value

An row- and/or column-ordered version of .fu_allocation_template

Examples

Template <- load_tidy_iea_df() %>% 
  specify_all() %>%
  fu_allocation_template()
Template
Template %>% 
  arrange_iea_fu_allocation_template()

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