collapse_to_tidy_psut: Collapse a tidy data frame of IEA data to a tidy PSUT data...

View source: R/psut.R

collapse_to_tidy_psutR Documentation

Collapse a tidy data frame of IEA data to a tidy PSUT data frame

Description

Call this function after calling ⁠add_row_col_meta()`` to collapse ⁠.tidy_iea_df' into a tidy PSUT data frame.

Usage

collapse_to_tidy_psut(
  .tidy_iea_df,
  matrix_class = c("matrix", "Matrix"),
  ledger_side = IEATools::iea_cols$ledger_side,
  flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
  flow = IEATools::iea_cols$flow,
  product = IEATools::iea_cols$product,
  e_dot = IEATools::iea_cols$e_dot,
  unit = IEATools::iea_cols$unit,
  B = IEATools::psut_cols$B,
  matnames = IEATools::mat_meta_cols$matnames,
  rownames = IEATools::mat_meta_cols$rownames,
  colnames = IEATools::mat_meta_cols$colnames,
  rowtypes = IEATools::mat_meta_cols$rowtypes,
  coltypes = IEATools::mat_meta_cols$coltypes,
  matvals = IEATools::psut_cols$matvals
)

Arguments

.tidy_iea_df

a data frame containing matnames and several other columns

matrix_class

The type of matrix to be created, one of "matrix" or "Matrix". Default is "matrix".

ledger_side, flow_aggregation_point, flow, product, e_dot, unit

See IEATools::iea_cols.

B

Name of the Balancing matrix. See IEATools::psut_cols.

matnames, rownames, colnames, rowtypes, coltypes

See IEATools::mat_meta_cols.

matvals

See IEATools::psut_cols.

Details

This function ensures that all energy flow numbers are positive before creating the matrices.

Note that the .tidy_iea_df is ungrouped using the function dplyr::ungroup() prior to undergoing any modification.

Value

.tidy_iea_df with all values converted to matrices in the matvals column

Examples

load_tidy_iea_df() %>% 
  specify_all() %>% 
  add_psut_matnames() %>% 
  add_row_col_meta() %>% 
  collapse_to_tidy_psut()

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