grouped_aggregates | R Documentation |
It is often helpful to aggregate data into industry or product categories,
such as "Anthracite" and "Brown coal" to "Coal and coal products" or
"Domestic aviation" and "Domestic navigation" to "Transport".
With the help of an aggregation_map
, this function
performs such aggregations for a set of PSUT matrices.
grouped_aggregates(
.sut_data = NULL,
aggregation_map,
margin = c(1, 2),
pattern_type = "exact",
R = Recca::psut_cols$R,
U = Recca::psut_cols$U,
U_feed = Recca::psut_cols$U_feed,
U_eiou = Recca::psut_cols$U_eiou,
r_eiou = Recca::psut_cols$r_eiou,
V = Recca::psut_cols$V,
Y = Recca::psut_cols$Y,
S_units = Recca::psut_cols$S_units,
R_aggregated_colname = paste0(Recca::psut_cols$R, aggregated_suffix),
U_aggregated_colname = paste0(Recca::psut_cols$U, aggregated_suffix),
U_feed_aggregated_colname = paste0(Recca::psut_cols$U_feed, aggregated_suffix),
U_eiou_aggregated_colname = paste0(Recca::psut_cols$U_eiou, aggregated_suffix),
r_eiou_aggregated_colname = paste0(Recca::psut_cols$r_eiou, aggregated_suffix),
V_aggregated_colname = paste0(Recca::psut_cols$V, aggregated_suffix),
Y_aggregated_colname = paste0(Recca::psut_cols$Y, aggregated_suffix),
S_units_aggregated_colname = paste0(Recca::psut_cols$S_units, aggregated_suffix),
aggregated_suffix = Recca::aggregate_cols$aggregated_suffix
)
.sut_data |
A data frame of matrices to be despecified and aggregated. |
aggregation_map |
Aggregation details. See documentation for |
margin |
|
pattern_type |
See |
R , U , U_feed , U_eiou , r_eiou , V , Y , S_units |
Matrices or names of columns in |
R_aggregated_colname , U_aggregated_colname , U_feed_aggregated_colname , U_eiou_aggregated_colname , r_eiou_aggregated_colname , V_aggregated_colname , Y_aggregated_colname , S_units_aggregated_colname |
Names of aggregated matrices or columns. |
aggregated_suffix |
A string suffix used to form the names for aggregated matrices. Default is "_aggregated". |
Internally, this function uses matsbyname::aggregate_byname()
.
See its documentation for details on the format for the aggregation_map
.
PSUT matrices aggregated according to aggregation_map
.
UKEnergy2000mats %>%
tidyr::pivot_wider(names_from = matrix.name, values_from = matrix) %>%
grouped_aggregates(aggregation_map = list(`Oil and oil products` =
c("Crude", "Diesel", "Petrol")),
pattern_type = "leading",
margin = "Product")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.