Skip to contents

Prepare data for a trajectory plot

Usage

prep_trajectory(
  data,
  convert_label = identity,
  span_5yr = FALSE,
  value_col = "percentage_of_initial_production_by_scope"
)

Arguments

data

A data frame. Requirements:

  • The structure must be like market_share.

  • The following columns must have a single value: sector, technology, region, scenario_source.

  • (Optional) If present, the column label is used for data labels.

convert_label

A symbol. The unquoted name of a function to apply to y-axis labels. For example:

  • To convert labels to uppercase use convert_label = toupper.

  • To get the default behavior of `

span_5yr

Logical. Use TRUE to restrict the time span to 5 years from the start year (the default behavior of qplot_trajectory()), or use FALSE to impose no restriction.

value_col

Character. Name of the column to be used as a value to be plotted.

Value

A data-frame ready to be plotted using plot_trajectory().

See also

Examples

# `data` must meet documented "Requirements"
data <- subset(
  market_share,
  sector == "power" &
    technology == "renewablescap" &
    region == "global" &
    scenario_source == "demo_2020"
)

prep_trajectory(data)
#> # A tibble: 105 × 12
#>    sector technology     year region scenario_source metric     production
#>    <chr>  <chr>         <int> <chr>  <chr>           <chr>           <dbl>
#>  1 power  renewablescap  2020 global demo_2020       projected       7380.
#>  2 power  renewablescap  2020 global demo_2020       target_cps      7380.
#>  3 power  renewablescap  2020 global demo_2020       target_sds      7380.
#>  4 power  renewablescap  2020 global demo_2020       target_sps      7380.
#>  5 power  renewablescap  2021 global demo_2020       projected       7361.
#>  6 power  renewablescap  2021 global demo_2020       target_cps      8077.
#>  7 power  renewablescap  2021 global demo_2020       target_sds      8539.
#>  8 power  renewablescap  2021 global demo_2020       target_sps      8221.
#>  9 power  renewablescap  2022 global demo_2020       projected       7342.
#> 10 power  renewablescap  2022 global demo_2020       target_cps      8774.
#> # ℹ 95 more rows
#> # ℹ 5 more variables: technology_share <dbl>, scope <chr>,
#> #   percentage_of_initial_production_by_scope <dbl>, label <chr>, value <dbl>