Skip to contents

This function verifies that there are no rows in common between the two input vectors.

Usage

sum_phi_vecs(
  phi_pf_vecs,
  phi_u_vecs,
  countries,
  country = IEATools::iea_cols$country,
  last_stage = IEATools::iea_cols$last_stage,
  energy_type = IEATools::iea_cols$energy_type,
  method = IEATools::iea_cols$method,
  phi_pf_colname = IEATools::template_cols$phi_pf,
  phi_u_colname = IEATools::template_cols$phi_u,
  phi_colname = IEATools::phi_constants_names$phi_colname,
  .nrow_diffs = ".nrow_diffs",
  .phi_shape_OK = ".phi_shape_OK",
  .phi_names_OK = ".phi_names_OK",
  .phi_cols_OK = ".phi_cols_OK",
  .phi_sum_OK = ".phi_sum_OK",
  .phi_pf_colnames = ".phi_pf_colnames",
  .phi_u_colnames = ".phi_u_colnames"
)

Arguments

phi_pf_vecs

A data frame of phi_pf vectors.

phi_u_vecs

A data frame of phi_u vectors.

countries

The countries for which you want to perform this task.

country, last_stage, energy_type, method

See IEATools::iea_cols.

phi_pf_colname, phi_u_colname

See IEATools::template_cols.

phi_colname

See IEATools::phi_constants_names.

.nrow_diffs, .phi_shape_OK, .phi_names_OK, .phi_cols_OK, .phi_sum_OK, .phi_pf_colnames, .phi_u_colnames

Names of temporary error-checking columns created internally.

Value

A data frame of summed phi_pf and phi_u vectors.

Examples

phi_pf_vec <- matrix(c(1.1,
                       1.05), nrow = 2, ncol = 1,
                     dimnames = list(c("Coal", "Oil"), "phi"))
# Make a data frame of phi_pf vectors
phi_pf <- tibble::tibble(phi.pf = RCLabels::make_list(phi_pf_vec, n = 2, lenx = 1),
                         Country = "GHA",
                         Year = c(1971, 2000))
phi_u_vec <- matrix(c(0.8,
                      0.9,
                      0.7), nrow = 3, ncol = 1,
                    dimnames = list(c("Light", "MD", "Propulsion"), "phi"))
phi_u <- tibble::tibble(phi.u = RCLabels::make_list(phi_u_vec, n = 2, lenx = 1),
                        Country = "GHA",
                        Year = c(1971, 2000))
sum_phi_vecs(phi_pf, phi_u, countries = "GHA")
#> # A tibble: 2 × 3
#>   Country  Year phi          
#>   <chr>   <dbl> <list>       
#> 1 GHA      1971 <dbl [5 × 1]>
#> 2 GHA      2000 <dbl [5 × 1]>