Skip to contents

Add a the jittered range of CO2 values

Usage

add_co2(data, co2, jitter_amount = NULL)

Arguments

data

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

co2

See co2 in tiltIndicator::emissions_profile().

jitter_amount

Numeric. Controls the amount of noise. Passed to amount in tiltIndicator::jitter_range().

Value

An object of the same class as data.

Examples

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

file <- toy_emissions_profile_products_ecoinvent()
co2 <- read_csv(file, show_col_types = FALSE)
profile <- toy_profile_emissions_impl_output()

with_co2 <- profile |> add_co2(co2)

product <- with_co2 |> unnest_product()

product |> relocate(matches(c("co2", "min", "max")))
#> # A tibble: 456 × 30
#>    co2_footprint min_headcount   min min_jitter max_headcount   max max_jitter
#>            <dbl>         <dbl> <dbl>      <dbl>         <dbl> <dbl>      <dbl>
#>  1          303.             1  303.      -190.            10  303.       706.
#>  2          303.             1  303.       300.            10  303.       623.
#>  3          303.             1  303.      -244.            10  303.       660.
#>  4          303.             1  303.       172.            10  303.       512.
#>  5          303.             1  303.      -262.            10  303.       338.
#>  6          303.             1  303.      -248.            10  303.       463.
#>  7          303.             1  303.      -190.            10  303.       706.
#>  8          303.             1  303.       300.            10  303.       623.
#>  9          303.             1  303.      -244.            10  303.       660.
#> 10          303.             1  303.       172.            10  303.       512.
#> # ℹ 446 more rows
#> # ℹ 23 more variables: companies_id <chr>, company_name <chr>, country <chr>,
#> #   emission_profile <chr>, benchmark <chr>, ep_product <chr>,
#> #   matched_activity_name <chr>, matched_reference_product <chr>, unit <chr>,
#> #   multi_match <lgl>, matching_certainty <chr>,
#> #   matching_certainty_company_average <chr>, tilt_sector <chr>,
#> #   tilt_subsector <chr>, isic_4digit <chr>, isic_4digit_name <chr>, …

product |> summarize_noise(.by = "benchmark")
#> # A tibble: 6 × 3
#>   benchmark           min_noise max_noise
#>   <chr>                   <dbl>     <dbl>
#> 1 all                     39.1      124. 
#> 2 isic_4digit              7.35     109. 
#> 3 tilt_subsector          22.6      116. 
#> 4 unit                    43.2       72.3
#> 5 unit_isic_4digit        18.3       17.5
#> 6 unit_tilt_subsector     21.2       49.5

with_co2 |>
  unnest_company() |>
  relocate(matches(c("co2")))
#> # A tibble: 1,728 × 15
#>    co2_avg companies_id              company_name country emission_profile_share
#>      <dbl> <chr>                     <chr>        <chr>                    <dbl>
#>  1    303. asteria_megalotomusquinq… asteria_meg… austria                      1
#>  2    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  3    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  4    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  5    303. asteria_megalotomusquinq… asteria_meg… austria                      1
#>  6    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  7    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  8    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#>  9    303. asteria_megalotomusquinq… asteria_meg… austria                      1
#> 10    303. asteria_megalotomusquinq… asteria_meg… austria                      0
#> # ℹ 1,718 more rows
#> # ℹ 10 more variables: emission_profile <chr>, benchmark <chr>,
#> #   matching_certainty_company_average <chr>, company_city <chr>,
#> #   postcode <chr>, address <chr>, main_activity <chr>,
#> #   profile_ranking_avg <dbl>, min_headcount <dbl>, max_headcount <dbl>