This function adds a column of matrix names to a tidy data frame
wherein each row of .DF
is a single value in an energy conversion chain.
The default argument values assume that .DF
uses IEA-style nomenclature
and terminology, although .DF
does not necessarily need to contain IEA data.
add_matnames_iea( .DF, ledger_side = "Ledger.side", energy = "E.dot", flow_aggregation_point = "Flow.aggregation.point", flow = "Flow", supply_side = "Supply", consumption_side = "Consumption", eiou = "Energy industry own use", neg_supply_in_fd = c("Exports", "International aviation bunkers", "International marine bunkers", "Losses", "Statistical differences", "Stock changes"), use_R = FALSE, matname = "matname", U_excl_EIOU = "U_excl_EIOU", U_EIOU = "U_EIOU", R = "R", V = "V", Y = "Y" )
.DF | a data frame with |
---|---|
ledger_side | the name of the column in |
energy | the name of the column in |
flow_aggregation_point | the name of the column in |
flow | the name of the column in |
supply_side | the identifier for items on the supply side of the ledger (a string).
Default is " |
consumption_side | the identifier for items on the consumption side
of the ledger (a string). Default is " |
eiou | the identifier for items that are energy industry own use.
Default is " |
neg_supply_in_fd | identifiers for |
use_R | tells whether to use a separate resources matrix ( |
matname | the name of the output column containing the name of the matrix
to which a row's value belongs (a string). Default is " |
U_excl_EIOU | the name for the use matrix that excludes energy industry own use (a string). Default is " |
U_EIOU | the name for the energy industry own use matrix. Default is " |
R | the name for the resource matrix (a string). Default is " |
V | the name for the make matrix (a string). Default is " |
Y | the name for the final demand matrix (a string). Default is " |
.DF
with an added column, matname
.
In a reasonable workflow, this function would be followed by a call to add_row_col_meta and collapse_to_matrices.
This function respects groups when identifying entries in the resource matrix (R
).
So be sure to group .DF
before calling this function, if that is warranted.
Internally, this function adds a temporary column to .DF
called ".R
".
An error will occur if .DF
already has a column named ".R
".
library(dplyr) UKEnergy2000tidy %>% group_by(Country, Year, Energy.type, Last.stage) %>% add_matnames_iea() %>% glimpse()#> Observations: 193 #> Variables: 11 #> Groups: Country, Year, Energy.type, Last.stage [4] #> $ Country <chr> "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR… #> $ Year <dbl> 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000… #> $ Ledger.side <chr> "Supply", "Supply", "Supply", "Supply", "Suppl… #> $ Flow.aggregation.point <chr> "Total primary energy supply", "Total primary … #> $ Energy.type <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "… #> $ Last.stage <chr> "Final", "Final", "Final", "Final", "Final", "… #> $ Flow <chr> "Resources - Crude", "Resources - NG", "Gas we… #> $ Product <chr> "Crude", "NG", "NG - Wells", "Crude - Fields",… #> $ E.dot <dbl> 50000, 43000, 43000, 50000, 47500, 41000, 2050… #> $ Unit <chr> "ktoe", "ktoe", "ktoe", "ktoe", "ktoe", "ktoe"… #> $ matname <chr> "V", "V", "V", "V", "V", "V", "V", "V", "V", "…