Arrange the rows and/or columns of a final-to-useful allocation template
arrange_iea_fu_allocation_template.Rd
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 = IEATools::iea_cols$ledger_side,
flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
ef_product = IEATools::template_cols$ef_product,
machine = IEATools::template_cols$machine,
eu_product = IEATools::template_cols$eu_product,
destination = IEATools::template_cols$destination,
unit = IEATools::iea_cols$unit,
fap_dest_order = IEATools::fap_flows,
ef_product_order = IEATools::products,
quantity = IEATools::template_cols$quantity,
maximum_values = IEATools::template_cols$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 "LedgerSide".- flow_aggregation_point
the flow aggregation point column in
.fu_allocation_template
. Default is FlowAggregationPoint.- ef_product
the name of the final energy column in
.fu_allocation_template
. Default isIEATools::template_cols$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 isIEATools::template_cols$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
anddestination
columns. Default isIEATools::fap_flow_iea_order
.- ef_product_order
the desired order for final energy products in
.fu_allocation_template
. Default isIEATools::products
.- 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 (
EfProduct
).Machine (the final-to-useful transformation process),
useful energy product (
EuProduct
),destination where the useful energy now flows,
years (in columns), and
allocations (C_x rows).
Examples
Template <- load_tidy_iea_df() %>%
specify_all() %>%
fu_allocation_template()
Template
#> # A tibble: 906 × 15
#> Country Method EnergyType LastStage LedgerSide FlowAggregationPoint Unit
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 GHA PCM E Final Supply Energy industry own use TJ
#> 2 GHA PCM E Final Supply Energy industry own use TJ
#> 3 GHA PCM E Final Supply Energy industry own use TJ
#> 4 GHA PCM E Final Supply Energy industry own use TJ
#> 5 GHA PCM E Final Supply Energy industry own use TJ
#> 6 GHA PCM E Final Supply Energy industry own use TJ
#> 7 GHA PCM E Final Supply Energy industry own use TJ
#> 8 GHA PCM E Final Supply Energy industry own use TJ
#> 9 GHA PCM E Final Supply Energy industry own use TJ
#> 10 GHA PCM E Final Supply Energy industry own use TJ
#> # ℹ 896 more rows
#> # ℹ 8 more variables: EfProduct <chr>, Machine <dbl>, EuProduct <dbl>,
#> # Destination <chr>, Quantity <chr>, MaximumValues <dbl>, `1971` <dbl>,
#> # `2000` <dbl>
Template %>%
arrange_iea_fu_allocation_template()
#> # A tibble: 906 × 15
#> Country Method EnergyType LastStage LedgerSide FlowAggregationPoint Unit
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 GHA PCM E Final Supply Energy industry own use TJ
#> 2 GHA PCM E Final Supply Energy industry own use TJ
#> 3 GHA PCM E Final Supply Energy industry own use TJ
#> 4 GHA PCM E Final Supply Energy industry own use TJ
#> 5 GHA PCM E Final Supply Energy industry own use TJ
#> 6 GHA PCM E Final Supply Energy industry own use TJ
#> 7 GHA PCM E Final Supply Energy industry own use TJ
#> 8 GHA PCM E Final Supply Energy industry own use TJ
#> 9 GHA PCM E Final Supply Energy industry own use TJ
#> 10 GHA PCM E Final Supply Energy industry own use TJ
#> # ℹ 896 more rows
#> # ℹ 8 more variables: EfProduct <chr>, Machine <dbl>, EuProduct <dbl>,
#> # Destination <chr>, Quantity <chr>, MaximumValues <dbl>, `1971` <dbl>,
#> # `2000` <dbl>