-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Co2e_lower
and Co2e_upper
variables in the output files
#117
Comments
Correct, the relevant functions are tiltIndicator helpers and can be used in tiltIndicatorAfter to add the range columns to the output tables. I believe you want one range per benchmark, correct? If so the information you want can be compressed in a table that has very few rows -- one per benchmark. We can still include it in the output table but the range columns will contain a lot of duplicated values (that's fine but just so you know). For example, see how much smaller is the library(dplyr, warn.conflicts = FALSE)
library(readr, warn.conflicts = FALSE)
library(tiltIndicator)
library(tiltToyData)
options(readr.show_col_types = FALSE, width = 500)
companies <- read_csv(toy_emissions_profile_any_companies())
products <- read_csv(toy_emissions_profile_products_ecoinvent())
result <- emissions_profile(companies, products)
product_result <- result |> unnest_product()
product_result
#> # A tibble: 2,736 × 7
#> companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid co2_footprint
#> <chr> <chr> <chr> <dbl> <chr> <chr> <dbl>
#> 1 soot_asianpiedstarling all low 0.111 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.405
#> 2 soot_asianpiedstarling all high 0.944 tent 76269c17-78d6-420b-991a-aa38c51b45b7 447.
#> 3 soot_asianpiedstarling all medium 0.556 tent 76269c17-78d6-420b-991a-aa38c51b45b7 14.1
#> 4 soot_asianpiedstarling all low 0.333 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.884
#> 5 soot_asianpiedstarling all high 0.778 tent 76269c17-78d6-420b-991a-aa38c51b45b7 321.
#> 6 soot_asianpiedstarling all low 0.278 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.675
#> 7 soot_asianpiedstarling isic_4digit low 0.333 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.405
#> 8 soot_asianpiedstarling isic_4digit high 0.833 tent 76269c17-78d6-420b-991a-aa38c51b45b7 447.
#> 9 soot_asianpiedstarling isic_4digit medium 0.667 tent 76269c17-78d6-420b-991a-aa38c51b45b7 14.1
#> 10 soot_asianpiedstarling isic_4digit high 1 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.884
#> # ℹ 2,726 more rows
range_summary <- product_result |>
summarize_range(co2_footprint, .by = "grouped_by") |>
jitter_range()
range_summary
#> # A tibble: 6 × 5
#> grouped_by min max min_jitter max_jitter
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 all 0.390 481. 0.389 1286.
#> 2 isic_4digit 0.390 481. 0.388 1217.
#> 3 tilt_sector 0.390 481. 0.389 729.
#> 4 unit 0.390 481. 0.389 2528.
#> 5 unit_isic_4digit 0.390 481. 0.390 2659.
#> 6 unit_tilt_sector 0.390 481. 0.389 4219.
left_join(product_result, range_summary) |>
relocate(matches(c("min", "max")))
#> Joining with `by = join_by(grouped_by)`
#> # A tibble: 2,736 × 11
#> min min_jitter max max_jitter companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid co2_footprint
#> <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <dbl>
#> 1 0.390 0.389 481. 1286. soot_asianpiedstarling all low 0.111 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.405
#> 2 0.390 0.389 481. 1286. soot_asianpiedstarling all high 0.944 tent 76269c17-78d6-420b-991a-aa38c51b45b7 447.
#> 3 0.390 0.389 481. 1286. soot_asianpiedstarling all medium 0.556 tent 76269c17-78d6-420b-991a-aa38c51b45b7 14.1
#> 4 0.390 0.389 481. 1286. soot_asianpiedstarling all low 0.333 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.884
#> 5 0.390 0.389 481. 1286. soot_asianpiedstarling all high 0.778 tent 76269c17-78d6-420b-991a-aa38c51b45b7 321.
#> 6 0.390 0.389 481. 1286. soot_asianpiedstarling all low 0.278 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.675
#> 7 0.390 0.388 481. 1217. soot_asianpiedstarling isic_4digit low 0.333 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.405
#> 8 0.390 0.388 481. 1217. soot_asianpiedstarling isic_4digit high 0.833 tent 76269c17-78d6-420b-991a-aa38c51b45b7 447.
#> 9 0.390 0.388 481. 1217. soot_asianpiedstarling isic_4digit medium 0.667 tent 76269c17-78d6-420b-991a-aa38c51b45b7 14.1
#> 10 0.390 0.388 481. 1217. soot_asianpiedstarling isic_4digit high 1 tent 76269c17-78d6-420b-991a-aa38c51b45b7 0.884
#> # ℹ 2,726 more rows Created on 2024-01-05 with reprex v2.0.2 |
@Tilmon I need this for my Bundesbank data, please let me know if this is a problem. |
Could you please add these two variables
Co2e_lower
andCo2e_upper
in the output table. This refers to this ticket 2DegreesInvesting/tiltIndicator#554. So I think the variables created with the jitter function creating the Co2 range per benchmark are already in the code but not in the output fileThe text was updated successfully, but these errors were encountered: