Create a data frame of phi_pf vectors
calc_phi_pf_vecs.Rd
This function creates a data frame that contains all the metadata columns
from phi_u_vecs
and a column of phi_pf vectors.
This work is accomplished by creating a vector from phi_constants
,
adding one instance of the vector to the right side of the phi_constants
data frame
for each row of the data frame,
and deleting phi_u_colname
from the data frame.
Usage
calc_phi_pf_vecs(
phi_constants,
phi_u_vecs,
countries,
matrix_class = c("matrix", "Matrix"),
country = IEATools::iea_cols$country,
product = IEATools::iea_cols$product,
eta_fu = IEATools::template_cols$eta_fu,
phi_u = IEATools::template_cols$phi_u,
phi_pf_colname = IEATools::template_cols$phi_pf,
phi_colname = IEATools::phi_constants_names$phi_colname,
is_useful_colname = IEATools::phi_constants_names$is_useful_colname
)
Arguments
- phi_constants
A data frame of constant phi values (for primary, final, and useful stages) with columns
product
,phi_colname
, andis_useful_colname
.- phi_u_vecs
A data frame containing metadata columns and a column of phi_u vectors. A column of phi_pf vectors replaces the column of phi_u vectors on output.
- countries
The countries for which you want to perform this task.
- matrix_class
A string that tells which type of matrix to create, a "matrix" (the built-in type) or a "Matrix" (could be sparse). Default is "matrix".
- country, product
See
IEATools::iea_cols
.- eta_fu, phi_u, phi_pf_colname
- phi_colname, is_useful_colname
See
IEATools::phi_constants_colnames
.
Value
A version of the phi_constants
data frame
with the column of useful phi (useful exergy-to-energy ratio) vectors
replaced by a column of primary and final phi vectors.
Examples
phi_constants <- IEATools::sample_phi_constants_path() %>%
IEATools::load_phi_constants_table()
phi_u_vecs <- tibble::tibble(Country = "GHA",
Year = 1971,
rownames = c("Light", "MD"),
colnames = "col",
matnames = "phi.u",
matvals = c(0.8, 0.9),
rowtypes = "rowtype",
coltypes = "coltype") %>%
dplyr::group_by(Country, Year) %>%
matsindf::collapse_to_matrices() %>%
dplyr::rename(phi.u = matvals) %>%
dplyr::mutate(
Quantity = NULL
)
calc_phi_pf_vecs(phi_constants, phi_u_vecs, countries = "GHA")
#> Country Year
#> 1 GHA 1971
#> phi.pf
#> 1 1.06, 1.06, 1.11, 1.00, 1.00, 1.00, 1.06, 1.06, 1.06, 1.06, 1.06, 1.06, 1.06, 1.05, 1.05, 1.00, 1.04, 1.04, 1.04, 1.04, 1.06, 1.00, 1.00, 1.00, 1.04, 1.11, 1.00, 1.05, 1.06, 1.00, 1.06, 1.06, 1.06, 1.11, 1.00, 0.60, 1.11, 0.60, 1.00, 1.11, 1.11, 1.06, 1.04, 1.06, 1.11, 1.00, 1.00, 1.11, 1.11, 1.00, 1.00, 1.11, 0.25, 1.11, 1.06, 1.06, 1.06, 1.06, 1.06, 1.00, 1.04, 1.00, 1.11, 1.06, 1.00, 1.11