Skip to contents

This function adds a column of ggplot2 graphs to a completed eta_fu tables data frame. The graphs are stored in a list column named plots.

Usage

eta_fu_plots_df(
  .df,
  countries,
  plots = "Plots",
  country = IEATools::iea_cols$country,
  year = IEATools::iea_cols$year,
  .values = IEATools::template_cols$.values,
  machine = IEATools::template_cols$machine,
  eu_product = IEATools::template_cols$eu_product,
  machine_eu_product = paste0(machine, "_", eu_product)
)

Arguments

.df

The completed final-to useful efficiency tables data frame, which contains both eta.fu and phi.u values.

countries

The countries for which final-to useful efficiency plots are to be created.

plots

The name of the output column containing final-to useful efficiency graphs. Default is "plots".

country

See IEATools::iea_cols.

year

See IEATools::iea_cols. Passed to alloc_graph().

.values, machine, eu_product

See IEATools::template_cols. Passed to eta_fu_graph().

machine_eu_product

The name of a combined machine and eu_product column.

Value

A data frame containing a list column of ggplot2 final-to useful efficiency graphs.

Details

By default, the completed eta_fu tables data frame is read from a drake cache.

The data frame is grouped by machine, and eu_product and nested prior to making the graphs, meaning that one final-to useful efficiency graph is constructed for each combination of machine, and eu_product.

Examples

# Make a simple data frame with the expected structure.
alloc_table <- tibble::tribble(~Country, ~Year, ~Ef.product, ~Destination,
                               ~.values, ~Machine, ~Eu.product,
                               "GHA", 1971, "Gasoline", "Transport",
                               0.5, "Cars", "MD",
                               "GHA", 1971, "Gasoline", "Transport",
                               0.5, "Trucks", "MD",
                               "GHA", 2020, "Gasoline", "Transport",
                               0.2, "Cars", "MD",
                               "GHA", 2020, "Gasoline", "Transport",
                               0.8, "Trucks", "MD",
                               "ZAF", 1971, "Gasoline", "Transport",
                               0.5, "Cars", "MD",
                               "ZAF", 1971, "Gasoline", "Transport",
                               0.5, "Trucks", "MD",
                               "ZAF", 2020, "Gasoline", "Transport",
                               0.3, "Cars", "MD",
                               "ZAF", 2020, "Gasoline", "Transport",
                               0.7, "Trucks", "MD")
alloc_plots_df(alloc_table, c("GHA", "ZAF"))
#> # A tibble: 2 × 5
#> # Groups:   Country, Ef.product, Destination [2]
#>   Country Ef.product Destination Data             Plots 
#>   <chr>   <chr>      <chr>       <list>           <list>
#> 1 GHA     Gasoline   Transport   <tibble [4 × 4]> <gg>  
#> 2 ZAF     Gasoline   Transport   <tibble [4 × 4]> <gg>