Skip to contents

Add transition risk score and polish the output for delivery

Usage

score_transition_risk_and_polish(
  emissions_profile,
  sector_profile,
  include_co2 = FALSE
)

Arguments

emissions_profile

Nested data frame. The output of profile_emissions().

sector_profile

Nested data frame. The output of profile_sector().

include_co2

Logical. Include co2_* columns ?

Value

A data frame with the column companies_id, and the nested columnsproduct and company holding the outputs at product and company level.

Examples

library(readr, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(tiltToyData, warn.conflicts = FALSE)

set.seed(123)
restore <- options(list(
  readr.show_col_types = FALSE,
  tiltIndicatorAfter.output_co2_footprint = TRUE
))

toy_emissions_profile_products_ecoinvent <- read_csv(toy_emissions_profile_products_ecoinvent())
toy_emissions_profile_any_companies <- read_csv(toy_emissions_profile_any_companies())
toy_sector_profile_any_scenarios <- read_csv(toy_sector_profile_any_scenarios())
toy_sector_profile_companies <- read_csv(toy_sector_profile_companies())
toy_europages_companies <- read_csv(toy_europages_companies())
toy_ecoinvent_activities <- read_csv(toy_ecoinvent_activities())
toy_ecoinvent_europages <- read_csv(toy_ecoinvent_europages())
toy_ecoinvent_inputs <- read_csv(toy_ecoinvent_inputs())
toy_isic_name <- read_csv(toy_isic_name())

emissions_profile <- profile_emissions(
  companies = toy_emissions_profile_any_companies,
  co2 = toy_emissions_profile_products_ecoinvent,
  europages_companies = toy_europages_companies,
  ecoinvent_activities = toy_ecoinvent_activities,
  ecoinvent_europages = toy_ecoinvent_europages,
  isic = toy_isic_name
)

sector_profile <- profile_sector(
  companies = toy_sector_profile_companies,
  scenarios = toy_sector_profile_any_scenarios,
  europages_companies = toy_europages_companies,
  ecoinvent_activities = toy_ecoinvent_activities,
  ecoinvent_europages = toy_ecoinvent_europages,
  isic = toy_isic_name
)

result <- score_transition_risk_and_polish(emissions_profile,
  sector_profile,
  include_co2 = TRUE
)

result |> unnest_product()
#> # A tibble: 1,824 × 32
#>    companies_id                country main_activity ep_product postcode address
#>    <chr>                       <chr>   <chr>         <chr>      <chr>    <chr>  
#>  1 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  2 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  3 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  4 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  5 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  6 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  7 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  8 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#>  9 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#> 10 asteria_megalotomusquinque… austria wholesaler    tent       3150     flesch…
#> # ℹ 1,814 more rows
#> # ℹ 26 more variables: activity_uuid_product_uuid <chr>,
#> #   matched_activity_name <chr>, matched_reference_product <chr>, unit <chr>,
#> #   co2e_lower <dbl>, co2e_upper <dbl>, emission_profile <chr>,
#> #   benchmark <chr>, profile_ranking <dbl>, min_headcount <dbl>,
#> #   max_headcount <dbl>, emissions_profile_best_case <dbl>,
#> #   emissions_profile_worst_case <dbl>, matching_certainty <chr>, …

result |> unnest_company()
#> # A tibble: 27,648 × 20
#>    companies_id    company_name country main_activity postcode address benchmark
#>    <chr>           <chr>        <chr>   <chr>         <chr>    <chr>   <chr>    
#>  1 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  2 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  3 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  4 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  5 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  6 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  7 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  8 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#>  9 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#> 10 asteria_megalo… asteria_meg… austria wholesaler    3150     flesch… all      
#> # ℹ 27,638 more rows
#> # ℹ 13 more variables: min_headcount <dbl>, max_headcount <dbl>,
#> #   emission_profile <chr>, emission_profile_share <dbl>,
#> #   profile_ranking_avg <dbl>, co2_avg <dbl>, sector_profile <chr>,
#> #   sector_profile_share <dbl>, scenario <chr>, year <dbl>,
#> #   reduction_targets_avg <dbl>, benchmark_tr_score_avg <chr>,
#> #   transition_risk_score_avg <dbl>

# Cleanup
options(restore)