write_ecc_to_excel: Write energy conversion chain matrices in an Excel file

View source: R/utilities.R

write_ecc_to_excelR Documentation

Write energy conversion chain matrices in an Excel file

Description

It is often helpful to see energy conversion chain (ECC) matrices in Excel format, arranged spatially. This function takes ECC matrices and writes them to an Excel file.

Usage

write_ecc_to_excel(
  .psut_data = NULL,
  path,
  overwrite_file = FALSE,
  pad = 2,
  include_io_mats = FALSE,
  R = Recca::psut_cols$R,
  U = Recca::psut_cols$U,
  V = Recca::psut_cols$V,
  Y = Recca::psut_cols$Y,
  r_eiou = Recca::psut_cols$r_eiou,
  U_eiou = Recca::psut_cols$U_eiou,
  U_feed = Recca::psut_cols$U_feed,
  S_units = Recca::psut_cols$S_units,
  .wrote_mats_colname = "Wrote mats",
  UV_bg_color = "#FDF2D0",
  RY_bg_color = "#D3712D",
  calculated_bg_color = "#D9D9D9",
  col_widths = 7
)

Arguments

.psut_data

A list or data frame of energy conversion chains.

path

The path of the Excel file to be created.

overwrite_file

A boolean that tells whether you want to overwrite the file at path, if it already exists.

pad

The number of rows and columns between adjacent matrices in the Excel sheet. Default is 2.

include_io_mats

A boolean that tells whether to include input-output matrices in the worksheets written by this function. Input-output matrices are obtained from calc_io_mats(). Default is FALSE.

R, U, U_feed, U_eiou, r_eiou, V, Y, S_units

Names of ECC matrices or actual matrices. See Recca::psut_cols.

.wrote_mats_colname

The name of the outgoing column that tells whether a worksheet was written successfully. Default is "Wrote mats".

UV_bg_color

The color of cells containing U and V matrices. Default is a creamy yellow.

RY_bg_color

The color of cells containing R and Y matrices. Default is a rust color.

calculated_bg_color

The color of cells containing calculated matrices. Default is gray.

col_widths

The widths of columns of matrices. Default is 7 to save space.

Details

If .psut_data is a PSUT data frame, each row is written to a different tab in the output file at path.

Value

An unmodified version of .psut_data (if not NULL) or a list of the incoming matrices.

Examples

## Not run: 
ecc <- UKEnergy2000mats %>%
  tidyr::spread(key = "matrix.name", value = "matrix")
ecc_temp_path <- tempfile(pattern = "write_excel_ecc_test_file", fileext = ".xlsx")
write_ecc_to_excel(ecc, path = ecc_temp_path, overwrite = TRUE)

## End(Not run)

MatthewHeun/Recca documentation built on Feb. 9, 2024, 6:18 p.m.