From fced484e0eb0ed52f532e08ce49d03622167fabd Mon Sep 17 00:00:00 2001 From: Kalash Singhal <125359076+kalashsinghal@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:26:23 +0200 Subject: [PATCH] Update article (#38) --- NAMESPACE | 5 +- R/example_data.R | 72 +++-- ...ample_emission_product_co2_des_analysis.Rd | 16 +- .../descriptive-analysis-products.Rmd | 294 +++++++++++++----- 4 files changed, 270 insertions(+), 117 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 3061bfc..3e26233 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,18 +2,19 @@ export(calculate_co2_descriptive_analysis_per_benchmark) export(calculate_trs_descriptive_analysis_per_tr_benchmark) -export(example_emission_ep_product_des_analysis) export(example_emission_product_best_case_worst_case) export(example_emission_product_co2_des_analysis) -export(example_sector_ep_product_des_analysis) export(example_transition_risk_company_emission_avg_best_case_worst_case) export(example_transition_risk_company_sector_avg_best_case_worst_case) export(example_transition_risk_company_transition_risk_avg_best_case_worst_case) +export(example_transition_risk_emission_ep_product_des_analysis) +export(example_transition_risk_ep_product_des_analysis) export(example_transition_risk_product_best_case_worst_case) export(example_transition_risk_product_emission_cov) export(example_transition_risk_product_sector_cov) export(example_transition_risk_product_transition_risk_cov) export(example_transition_risk_product_trs_des_analysis) +export(example_transition_risk_sector_ep_product_des_analysis) export(show_reduction_targets_for_tilt_subsectors_per_grouping_sector) importFrom(dplyr,arrange) importFrom(dplyr,distinct) diff --git a/R/example_data.R b/R/example_data.R index 7b9ef05..828b08b 100644 --- a/R/example_data.R +++ b/R/example_data.R @@ -10,8 +10,6 @@ #' @examples #' example_emission_product_co2_des_analysis() #' example_transition_risk_product_trs_des_analysis() -#' example_emission_ep_product_des_analysis() -#' example_sector_ep_product_des_analysis() #' example_transition_risk_product_emission_cov() #' example_transition_risk_product_sector_cov() #' example_transition_risk_product_transition_risk_cov() @@ -20,6 +18,9 @@ #' example_transition_risk_company_sector_avg_best_case_worst_case() #' example_transition_risk_product_best_case_worst_case() #' example_transition_risk_company_transition_risk_avg_best_case_worst_case() +#' example_transition_risk_emission_ep_product_des_analysis() +#' example_transition_risk_sector_ep_product_des_analysis() +#' example_transition_risk_ep_product_des_analysis() example_emission_product_co2_des_analysis <- function() { tribble( # styler: off @@ -64,36 +65,60 @@ example_transition_risk_product_trs_des_analysis <- function() { #' @export #' @rdname example_emission_product_co2_des_analysis -example_emission_ep_product_des_analysis <- function() { +example_transition_risk_emission_ep_product_des_analysis <- function() { tribble( # styler: off - ~companies_id, ~ep_product, ~emission_profile, - "comp_1", "a", "high", - "comp_1", "b", "high", - "comp_1", "c", "high", - "comp_1", "d", NA_character_, - "comp_1", "e", NA_character_, - "comp_2", "a", "high", - "comp_2", "b", "high", - "comp_2", "c", "high" - # styler: on + ~companies_id, ~product, ~grouping_emission, ~emission_category, + "comp_1", "a", "all", "high", + "comp_1", "b", "all", "high", + "comp_1", "c", "all", "high", + "comp_1", "d", NA_character_, NA_character_, + "comp_1", "e", NA_character_, NA_character_, + "comp_2", "a", "all", "high", + "comp_2", "b", "all", "high", + "comp_2", "c", "all", "high", + "comp_3", "d", NA_character_, NA_character_, + "comp_3", "e", NA_character_, NA_character_ + # styler: on + ) +} + +#' @export +#' @rdname example_emission_product_co2_des_analysis +example_transition_risk_sector_ep_product_des_analysis <- function() { + tribble( + # styler: off + ~companies_id, ~product, ~sector_target, ~sector_category, + "comp_1", "a", 0.12, "high", + "comp_1", "b", 0.96, "high", + "comp_1", "c", 0.64, "high", + "comp_1", "d", NA_real_, NA_character_, + "comp_1", "e", NA_real_, NA_character_, + "comp_2", "a", 0.12, "high", + "comp_2", "b", 0.96, "high", + "comp_2", "c", 0.64, "high", + "comp_3", "d", NA_real_, NA_character_, + "comp_3", "e", NA_real_, NA_character_ + # styler: on ) } #' @export #' @rdname example_emission_product_co2_des_analysis -example_sector_ep_product_des_analysis <- function() { +example_transition_risk_ep_product_des_analysis <- function() { tribble( # styler: off - ~companies_id, ~ep_product, ~sector_profile, - "comp_1", "a", "high", - "comp_1", "b", "high", - "comp_1", "c", "high", - "comp_1", "d", NA_character_, - "comp_1", "e", NA_character_, - "comp_2", "a", "high", - "comp_2", "b", "high", - "comp_2", "c", "high" + ~companies_id, ~product, ~grouping_transition_risk, ~transition_risk_category, + "comp_1", "a", "1.5C RPS_2030_all", "high", + "comp_1", "b", "1.5C RPS_2030_all", "high", + "comp_1", "c", "1.5C RPS_2030_all", "high", + "comp_1", "d", NA_character_, NA_character_, + "comp_1", "e", NA_character_, NA_character_, + "comp_2", "a", "1.5C RPS_2030_all", "high", + "comp_2", "b", "1.5C RPS_2030_all", "high", + "comp_2", "c", "1.5C RPS_2030_all", "high", + "comp_3", "d", NA_character_, NA_character_, + "comp_3", "e", NA_character_, NA_character_ # styler: on ) } @@ -308,3 +333,4 @@ example_transition_risk_company_transition_risk_avg_best_case_worst_case <- func # styler: on ) } + diff --git a/man/example_emission_product_co2_des_analysis.Rd b/man/example_emission_product_co2_des_analysis.Rd index 1ca7df1..28e3b2e 100644 --- a/man/example_emission_product_co2_des_analysis.Rd +++ b/man/example_emission_product_co2_des_analysis.Rd @@ -3,8 +3,9 @@ \name{example_emission_product_co2_des_analysis} \alias{example_emission_product_co2_des_analysis} \alias{example_transition_risk_product_trs_des_analysis} -\alias{example_emission_ep_product_des_analysis} -\alias{example_sector_ep_product_des_analysis} +\alias{example_transition_risk_emission_ep_product_des_analysis} +\alias{example_transition_risk_sector_ep_product_des_analysis} +\alias{example_transition_risk_ep_product_des_analysis} \alias{example_transition_risk_product_emission_cov} \alias{example_transition_risk_product_sector_cov} \alias{example_transition_risk_product_transition_risk_cov} @@ -19,9 +20,11 @@ example_emission_product_co2_des_analysis() example_transition_risk_product_trs_des_analysis() -example_emission_ep_product_des_analysis() +example_transition_risk_emission_ep_product_des_analysis() -example_sector_ep_product_des_analysis() +example_transition_risk_sector_ep_product_des_analysis() + +example_transition_risk_ep_product_des_analysis() example_transition_risk_product_emission_cov() @@ -49,8 +52,6 @@ package. \examples{ example_emission_product_co2_des_analysis() example_transition_risk_product_trs_des_analysis() -example_emission_ep_product_des_analysis() -example_sector_ep_product_des_analysis() example_transition_risk_product_emission_cov() example_transition_risk_product_sector_cov() example_transition_risk_product_transition_risk_cov() @@ -59,5 +60,8 @@ example_transition_risk_company_emission_avg_best_case_worst_case() example_transition_risk_company_sector_avg_best_case_worst_case() example_transition_risk_product_best_case_worst_case() example_transition_risk_company_transition_risk_avg_best_case_worst_case() +example_transition_risk_emission_ep_product_des_analysis() +example_transition_risk_sector_ep_product_des_analysis() +example_transition_risk_ep_product_des_analysis() } \keyword{internal} diff --git a/vignettes/articles/descriptive-analysis-products.Rmd b/vignettes/articles/descriptive-analysis-products.Rmd index 34e8ffc..e9963d4 100644 --- a/vignettes/articles/descriptive-analysis-products.Rmd +++ b/vignettes/articles/descriptive-analysis-products.Rmd @@ -9,6 +9,14 @@ knitr::opts_chunk$set( ) ``` +```{css, echo=FALSE} +@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap'); + +table { + font-family: 'Roboto Condensed', sans-serif; +} +``` + This article shows how to calculate the descriptive analysis of products for emission and sector profile. @@ -18,58 +26,84 @@ library(dplyr) library(knitr) library(tiltDataAnalysis) library(stringr) +library(tiltToyData) +library(readr) options(readr.show_col_types = FALSE) ``` -### Example subset of product-level output of emissions profile. +### Distinct europages products -```{r} -emission_product_example <- example_emission_ep_product_des_analysis() -kable(emission_product_example |> head(20)) +#### Input + +```{r, echo=FALSE} +example_europages_companies <- read_csv(toy_europages_companies()) |> head(10) +kable(example_europages_companies) ``` -### Example subset of product-level output of sector profile. +#### Output -```{r} -sector_product_example <- example_sector_ep_product_des_analysis() -kable(sector_product_example |> head(20)) +```{r, results='asis'} +cat("Distinct europages products:", n_distinct(example_europages_companies$clustered)) ``` -### Distinct products of emission and sector profile +### Distinct europages products that matched to ecoinvent -```{r, results='asis'} -cat("Distinct products of emission profile:", n_distinct(emission_product_example$ep_product)) -cat("Distinct products of sector profile:", n_distinct(sector_product_example$ep_product)) +#### Input + +```{r, echo=FALSE} +# base_input <- read_csv("transition_risk_profile_at_product_level_all_countries_wide_21_08_24.csv") +example_emission_profile <- example_transition_risk_emission_ep_product_des_analysis() +kable(example_emission_profile) ``` -### Matched distinct products of emission and sector profile +#### Output ```{r, echo=FALSE} -matched_distinct_products <- function(data, profile) { - result <- data |> - select(all_of(c("ep_product", profile))) |> - distinct() |> - filter(!is.na(.data[[profile]])) - - n_distinct(result$ep_product) -} +matched_ecoinvent <- example_emission_profile |> + select(all_of(c("product", "emission_category"))) |> + filter(!is.na(emission_category)) |> + distinct() ``` ```{r, results='asis'} -cat("Matched distinct products of emission profile:", matched_distinct_products(emission_product_example, "emission_profile")) -cat("Matched distinct products of sector profile:", matched_distinct_products(sector_product_example, "sector_profile")) +cat("Distinct europages products:", n_distinct(matched_ecoinvent$product)) ``` -### Average amount of distinct products per company for emission and sector profile +### Distinct europages products that have `sector_target` + +#### Input ```{r, echo=FALSE} -avg_distinct_products_per_company <- function(data) { +example_sector_profile <- example_transition_risk_sector_ep_product_des_analysis() +kable(example_sector_profile) +``` + +#### Output + +```{r, echo=FALSE} +products_sector_target <- example_sector_profile |> + select(all_of(c("product", "sector_target"))) |> + filter(!is.na(sector_target)) |> + distinct() +``` + +```{r, results='asis'} +cat("Distinct europages products:", n_distinct(products_sector_target$product)) +``` + +### Average amount of distinct products per company for emission profile if the company have atleast one matched ecoinvent product + +```{r} +avg_distinct_products_per_company_atleast_one_matched_ecoinvent <- function(data, col) { + companies_with_atleast_one_matched_product <- data |> + select(all_of(c("companies_id", "product", col))) |> + filter(!is.na(.data[[col]])) |> + distinct() result <- data |> - rename(any_of(c(ep_product = "product"))) |> - select(all_of(c("companies_id", "ep_product"))) |> - distinct() |> - mutate(distinct_products_per_company = n_distinct(ep_product, na.rm = TRUE), .by = "companies_id") |> - select(-all_of(c("ep_product"))) |> + select(all_of(c("companies_id", "product"))) |> + filter(companies_id %in% companies_with_atleast_one_matched_product$companies_id) |> + mutate(distinct_products_per_company = n_distinct(product, na.rm = TRUE), .by = "companies_id") |> + select(-all_of(c("product"))) |> distinct() sum(result$distinct_products_per_company) / n_distinct(result$companies_id) @@ -77,41 +111,63 @@ avg_distinct_products_per_company <- function(data) { ``` ```{r, results='asis'} -cat("Average amount of distinct products per company for emission profile:", avg_distinct_products_per_company(emission_product_example)) -cat("Average amount of distinct products per company for sector profile:", avg_distinct_products_per_company(sector_product_example)) +cat("Average amount of distinct products per company for emission profile if the company have atleast one matched ecoinvent product:", avg_distinct_products_per_company_atleast_one_matched_ecoinvent(example_emission_profile, "emission_category")) +``` + +### Average amount of distinct products per company for sector profile if the company have atleast one product with sector target + +```{r, results='asis'} +cat("Average amount of distinct products per company for sector profile if the company have atleast one product with sector target:", avg_distinct_products_per_company_atleast_one_matched_ecoinvent(example_sector_profile, "sector_category")) ``` -### Average amount of distinct products per company for transition risk profile +### Average amount of distinct products per company for transition risk profile if the company have atleast one product with transition risk category + +#### Input ```{r, echo=FALSE} -transition_risk_product_example <- product_transition_risk |> - select(c("companies_id", "product")) |> - distinct() |> - filter(product %in% c("prefabricated houses", "porches, metal")) +example_transition_risk_profile <- example_transition_risk_ep_product_des_analysis() +kable(example_transition_risk_profile) +``` + +```{r, results='asis'} +cat("Average amount of distinct products per company for sector profile if the company have atleast one product with sector target:", avg_distinct_products_per_company_atleast_one_matched_ecoinvent(example_transition_risk_profile, "transition_risk_category")) +``` + +### Average amount of distinct products per company + +```{r, echo=FALSE} +avg_distinct_products_per_company <- function(data) { + result <- data |> + select(all_of(c("companies_id", "product"))) |> + mutate(distinct_products_per_company = n_distinct(product, na.rm = TRUE), .by = "companies_id") |> + select(-all_of(c("product"))) |> + distinct() -kable(transition_risk_product_example) + sum(result$distinct_products_per_company) / n_distinct(result$companies_id) +} ``` ```{r, results='asis'} -cat("Average amount of distinct products per company for transition risk profile:", avg_distinct_products_per_company(transition_risk_product_example)) +cat("Average amount of distinct products per company: ", avg_distinct_products_per_company(example_transition_risk_profile)) ``` -### Distinct products without a risk category for emission and sector profile +### Distinct products without a risk category for emission, sector, and transition risk profile ```{r, echo=FALSE} distinct_products_without_risk_category <- function(data, profile) { result <- data |> - select(all_of(c("ep_product", profile))) |> + select(all_of(c("product", profile))) |> distinct() |> - filter(!is.na(ep_product) & is.na(.data[[profile]])) + filter(is.na(.data[[profile]])) - n_distinct(result$ep_product) + n_distinct(result$product) } ``` ```{r, results='asis'} -cat("Distinct products without a risk category for emission profile:", distinct_products_without_risk_category(emission_product_example, "emission_profile")) -cat("Distinct products without a risk category for sector profile:", distinct_products_without_risk_category(sector_product_example, "sector_profile")) +cat("Distinct products without a risk category for emission profile:", distinct_products_without_risk_category(example_emission_profile, "emission_category")) +cat("Distinct products without a risk category for sector profile:", distinct_products_without_risk_category(example_sector_profile, "sector_category")) +cat("Distinct products without a risk category for transition risk profile:", distinct_products_without_risk_category(example_transition_risk_profile, "transition_risk_category")) ``` ### Average profile ranking of all products per grouping_emission @@ -119,11 +175,12 @@ cat("Distinct products without a risk category for sector profile:", distinct_pr #### Input ```{r, echo=FALSE} -profile_rank_df <- product_emission |> - select(all_of(c("ep_product", "benchmark", "profile_ranking"))) |> - rename("grouping_emission" = "benchmark") |> +transition_risk_product <- product_transition_risk +profile_rank_df <- transition_risk_product |> + select(all_of(c("product", "grouping_emission", "emission_rank"))) |> + filter(grouping_emission %in% c("all", "tilt_subsector")) |> distinct() |> - filter(ep_product %in% c("tent", "surface engineering")) + filter(product %in% c("tent", "surface engineering")) ``` ```{r, results='asis', echo=FALSE} @@ -132,20 +189,19 @@ kable(profile_rank_df |> head(10)) #### Output -```{r, echo=FALSE} +```{r} avg_profile_ranking_df <- profile_rank_df |> - mutate(sum_profile_ranking = sum(.data$profile_ranking, na.rm = TRUE), .by = "grouping_emission") |> - mutate(distinct_products_per_benchmark = n_distinct(.data$ep_product, na.rm = TRUE), .by = "grouping_emission") |> - mutate(avg_profile_ranking = sum_profile_ranking/distinct_products_per_benchmark) |> - select(-all_of(c("sum_profile_ranking", "distinct_products_per_benchmark", "profile_ranking", "ep_product"))) |> - distinct() |> - filter(!str_detect(grouping_emission, "NA")) + mutate(sum_profile_ranking = sum(.data$emission_rank, na.rm = TRUE), .by = "grouping_emission") |> + mutate(distinct_products_per_benchmark = n_distinct(.data$product, na.rm = TRUE), .by = "grouping_emission") |> + mutate("emission rank average" = sum_profile_ranking/distinct_products_per_benchmark) |> + select(-all_of(c("sum_profile_ranking", "distinct_products_per_benchmark", "emission_rank", "product"))) |> + distinct() ``` ```{r, results='asis', echo=FALSE} kable(avg_profile_ranking_df, align = "lc", caption = "Average profile ranking of all products per grouping_emission", escape = F) |> - kable_classic(full_width = F, html_font = "Cambria") |> - column_spec(1:2, width = "2.5cm") + kable_classic(full_width = F, html_font = "Roboto Condensed") |> + column_spec(1:2, width = "4cm") ``` ### Average reduction targets of all products per grouping_sector @@ -153,12 +209,12 @@ kable(avg_profile_ranking_df, align = "lc", caption = "Average profile ranking o #### Input ```{r, echo=FALSE} -reduction_targets_df <- product_sector |> - select(all_of(c("ep_product", "scenario", "year", "reduction_targets"))) |> +reduction_targets_df <- transition_risk_product |> + select(all_of(c("product", "scenario", "year", "sector_target"))) |> distinct() |> mutate(grouping_sector = paste(.data$scenario, .data$year, sep = "_")) |> select(-all_of(c("scenario", "year"))) |> - filter(ep_product %in% c("tent", "surface engineering")) + filter(product %in% c("tent", "surface engineering")) ``` ```{r, echo=FALSE} @@ -169,18 +225,18 @@ kable(reduction_targets_df |> head(10)) ```{r, echo=FALSE} avg_reduction_targets_df <- reduction_targets_df |> - mutate(sum_reduction_targets = sum(.data$reduction_targets, na.rm = TRUE), .by = "grouping_sector") |> - mutate(distinct_products_per_scenario_year = n_distinct(.data$ep_product, na.rm = TRUE), .by = "grouping_sector") |> - mutate(avg_reduction_targets = sum_reduction_targets/distinct_products_per_scenario_year) |> - select(-all_of(c("sum_reduction_targets", "distinct_products_per_scenario_year", "reduction_targets", "ep_product"))) |> + mutate(sum_reduction_targets = sum(.data$sector_target, na.rm = TRUE), .by = "grouping_sector") |> + mutate(distinct_products_per_scenario_year = n_distinct(.data$product, na.rm = TRUE), .by = "grouping_sector") |> + mutate("sector target average" = sum_reduction_targets/distinct_products_per_scenario_year) |> + select(-all_of(c("sum_reduction_targets", "distinct_products_per_scenario_year", "sector_target", "product"))) |> distinct() |> filter(!str_detect(grouping_sector, "NA")) ``` ```{r, results='asis', echo=FALSE} kable(avg_reduction_targets_df, align = "lc", caption = "Average reduction targets of all products per grouping_sector", escape = F) |> - kable_classic(full_width = F, html_font = "Cambria") |> - column_spec(2, width = "5cm") + kable_classic(full_width = F, html_font = "Roboto Condensed") |> + column_spec(1:2, width = "4cm") ``` ### Average transition risk scores of all products per tilt_subsector benchmarks @@ -188,11 +244,13 @@ kable(avg_reduction_targets_df, align = "lc", caption = "Average reduction targe #### Input ```{r, echo=FALSE} -trs_df <- product_transition_risk |> +trs_df <- transition_risk_product |> select(all_of(c("product", "grouping_transition_risk", "transition_risk_score"))) |> distinct() |> filter(grouping_transition_risk %in% c("1.5C RPS_2030_tilt_subsector", "1.5C RPS_2050_tilt_subsector", - "NZ 2050_2030_tilt_subsector", "NZ 2050_2050_tilt_subsector")) |> + "NZ 2050_2030_tilt_subsector", "NZ 2050_2050_tilt_subsector", + "1.5C RPS_2030_all", "1.5C RPS_2050_all", + "NZ 2050_2030_all", "NZ 2050_2050_all")) |> filter(product %in% c("tent", "surface engineering")) ``` @@ -206,49 +264,113 @@ kable(trs_df |> head(10)) avg_trs_df <- trs_df |> mutate(sum_trs = sum(.data$transition_risk_score, na.rm = TRUE), .by = "grouping_transition_risk") |> mutate(distinct_products_per_benchmark = n_distinct(.data$product, na.rm = TRUE), .by = "grouping_transition_risk") |> - mutate(avg_transition_risk_scores = sum_trs/distinct_products_per_benchmark) |> + mutate("transition risk average" = sum_trs/distinct_products_per_benchmark) |> select(-all_of(c("sum_trs", "distinct_products_per_benchmark", "transition_risk_score", "product"))) |> distinct() + +avg_trs_df$group <- sub(".*0_", "", avg_trs_df$grouping_transition_risk) +avg_trs_df$scenario <- sub("(0)_.*", "\\1", avg_trs_df$grouping_transition_risk) +avg_trs_df <- avg_trs_df |> + select(-all_of(c("grouping_transition_risk"))) |> + relocate(all_of(c("group", "scenario"))) ``` ```{r, results='asis', echo=FALSE} -kable(avg_trs_df, align = "lc", caption = "Average reduction targets of all products per benchmarks", escape = F) |> - kable_classic(full_width = F, html_font = "Cambria") |> - column_spec(2, width = "5cm") +kable(avg_trs_df, align = "llc", caption = "Average transition risk scores of all products per transition risk groups", escape = F) |> + kable_classic(full_width = F, html_font = "Roboto Condensed") |> + column_spec(1, width = "3cm") |> + column_spec(3, width = "5cm") |> + collapse_rows(columns = 1, valign = "top") ``` -### Average NA share per company with atleast one matched product for emission profile +### Average NA share per company -#### Companies with atleast one matched product +#### Companies with atleast one matched product for emission profile ```{r, echo = FALSE} -companies_atleast_one_matched_product <- product_emission |> - select(all_of(c("companies_id", "ep_product", "emission_profile"))) |> - distinct() |> - filter(!is.na(emission_profile)) +transition_risk_company <- company_transition_risk +# read_csv("transition_risk_profile_at_company_level_all_countries_wide_21_08_24.csv") + +companies_atleast_one_product_per_profile <- function(data, profile) { + data |> + select(all_of(c("companies_id", "product", profile))) |> + filter(!is.na(.data[[profile]])) |> + distinct() +} ``` ```{r, results='asis', echo=FALSE} -kable(companies_atleast_one_matched_product |> head(10)) +companies_atleast_one_product_emission_profile <- companies_atleast_one_product_per_profile(transition_risk_product, "emission_category") +kable(companies_atleast_one_product_emission_profile |> head(10)) ``` -#### Average NA share per company which have atleast one matched product +#### Average NA share per company which have atleast one matched product for emission profile ```{r, echo=FALSE} -result <- company_transition_risk |> +na_emission_profile <- transition_risk_company |> select(all_of(c("companies_id", "emission_category_NA"))) |> distinct() |> - filter(companies_id %in% companies_atleast_one_matched_product$companies_id) + filter(companies_id %in% companies_atleast_one_product_emission_profile$companies_id) + +kable(na_emission_profile |> head(10)) +``` + +```{r, echo=FALSE} +average_na_emission_profile <- sum(na_emission_profile$emission_category_NA, na.rm = TRUE) / n_distinct(na_emission_profile$companies_id) ``` +```{r, results='asis'} +cat("Average NA share per company with atleast one matched product for emission profile:", average_na_emission_profile) +``` + +#### Companies with atleast one product with sector category + +```{r, results='asis', echo=FALSE} +companies_atleast_one_product_sector_profile <- companies_atleast_one_product_per_profile(transition_risk_product, "sector_category") +kable(companies_atleast_one_product_emission_profile |> head(10)) +``` + +#### Average NA share per company which have atleast one product with sector category + +```{r, echo=FALSE} +na_sector_profile <- transition_risk_company |> + select(all_of(c("companies_id", "sector_category_NA"))) |> + distinct() |> + filter(companies_id %in% companies_atleast_one_product_sector_profile$companies_id) + +kable(na_sector_profile |> head(10)) +``` + +```{r, echo=FALSE} +average_na_sector_profile <- sum(na_sector_profile$sector_category_NA, na.rm = TRUE) / n_distinct(na_sector_profile$companies_id) +``` + +```{r, results='asis'} +cat("Average NA share per company with atleast one product with sector category:", average_na_sector_profile) +``` + +#### Companies with atleast one product with transition risk category + ```{r, results='asis', echo=FALSE} -kable(result |> head(10)) +companies_atleast_one_product_transition_risk_profile <- companies_atleast_one_product_per_profile(transition_risk_product, "transition_risk_category") +kable(companies_atleast_one_product_transition_risk_profile |> head(10)) +``` + +#### Average NA share per company which have atleast one product with transition risk category + +```{r, echo=FALSE} +na_transition_risk_profile <- transition_risk_company |> + select(all_of(c("companies_id", "transition_risk_NA_share"))) |> + distinct() |> + filter(companies_id %in% companies_atleast_one_product_transition_risk_profile$companies_id) + +kable(na_transition_risk_profile |> head(10)) ``` ```{r, echo=FALSE} -average_result <- sum(result$emission_category_NA, na.rm = TRUE) / n_distinct(result$companies_id) +average_na_transition_risk_profile <- sum(na_transition_risk_profile$transition_risk_NA_share, na.rm = TRUE) / n_distinct(na_transition_risk_profile$companies_id) ``` ```{r, results='asis'} -cat("Average NA share per company with atleast one matched product for emission profile:", average_result) +cat("Average NA share per company with atleast one product with transition risk category:", average_na_transition_risk_profile) ```