At product level, all functions now output profile_ranking#613
At product level, all functions now output profile_ranking#613maurolepore merged 2 commits intomainfrom
profile_ranking#613Conversation
profile_ranking
profile_rankingprofile_ranking
profile_rankingprofile_ranking
|
Dear @maurolepore, First I think to add the profile_ranking in those csv files are fine. Please note that you don't need to do it for the company dataset as you said. Some questions:
|
|
Thanks @AnneSchoenauer for your feedback. Yes, the reprex above was extremely minimal to clearly show the new colum To see how it varies across rows we need a more complex reprex. Here I use our toy datasets. I think it answers your questions 1 and 3. RE the inconsistency across the values of My suggestion is to remove the "input_" prefix. If anyone wonders where the columns come from (products or inputs), they can simply see the name of the dataset, e.g. library(tiltToyData)
library(readr, warn.conflicts = FALSE)
options(readr.show_col_types = FALSE, width = 500)
# PR tiltIndicator #613
devtools::load_all()
#> ℹ Loading tiltIndicator
companies <- read_csv(toy_emissions_profile_any_companies())
products <- read_csv(toy_emissions_profile_products())
emissions_profile(companies, products) |> unnest_product()
#> # A tibble: 49 × 7
#> companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid co2_footprint
#> <chr> <chr> <chr> <dbl> <chr> <chr> <dbl>
#> 1 fleischerei-stiefsohn_00000005219477-001 all high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 2 fleischerei-stiefsohn_00000005219477-001 isic_4digit high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 3 fleischerei-stiefsohn_00000005219477-001 tilt_sector high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 4 fleischerei-stiefsohn_00000005219477-001 unit high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 5 fleischerei-stiefsohn_00000005219477-001 unit_isic_4digit high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 6 fleischerei-stiefsohn_00000005219477-001 unit_tilt_sector high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 176.
#> 7 fleischerei-stiefsohn_00000005219477-001 all high 0.8 oven be06d25c-73dc-55fb-965b-0f300453e380_98b48ff2-2200-4b08-9dec-9c7c0e3585bc 58.1
#> 8 fleischerei-stiefsohn_00000005219477-001 isic_4digit medium 0.5 oven be06d25c-73dc-55fb-965b-0f300453e380_98b48ff2-2200-4b08-9dec-9c7c0e3585bc 58.1
#> 9 fleischerei-stiefsohn_00000005219477-001 tilt_sector medium 0.667 oven be06d25c-73dc-55fb-965b-0f300453e380_98b48ff2-2200-4b08-9dec-9c7c0e3585bc 58.1
#> 10 fleischerei-stiefsohn_00000005219477-001 unit medium 0.5 oven be06d25c-73dc-55fb-965b-0f300453e380_98b48ff2-2200-4b08-9dec-9c7c0e3585bc 58.1
#> # ℹ 39 more rows
companies <- read_csv(toy_emissions_profile_any_companies())
products <- read_csv(toy_emissions_profile_products())
inputs <- read_csv(toy_emissions_profile_upstream_products())
emissions_profile_upstream(companies, inputs) |> unnest_product()
#> # A tibble: 319 × 8
#> companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid input_activity_uuid_product_uuid input_co2_footprint
#> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl>
#> 1 fleischerei-stiefsohn_00000005219477-001 all high 0.909 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5 7.07e+0
#> 2 fleischerei-stiefsohn_00000005219477-001 all high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 1aeb18b9-8355-560f-82aa-543c771c4d61_a0e53510-b90b-43ba-80cc-7600f5d 3.99e+1
#> 3 fleischerei-stiefsohn_00000005219477-001 all medium 0.636 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 22704506-7707-5ae7-990d-ebf01ac04fb5_50c41012-3b00-429d-ace3-40d0 5.12e-1
#> 4 fleischerei-stiefsohn_00000005219477-001 all high 0.758 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 92078219-1ed3-5215-9f70-931cdefad520_5c21b18e-e32d-4c76-8d16-2238632 1.24e+0
#> 5 fleischerei-stiefsohn_00000005219477-001 all high 0.970 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 9d483329-b09a-5513-b1bc-722cb211e928_bd4dca-497e-bdd9-fcd343012087 2.12e+1
#> 6 fleischerei-stiefsohn_00000005219477-001 all low 0.0909 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 8709b463-732e-592e-9b88-999ed17af48f_6b6b3a15-e0-baea-cda98afc61c2 1.24e-9
#> 7 fleischerei-stiefsohn_00000005219477-001 all low 0.121 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa d44e7db1-4dda-51ed2929a8f1a2_32e60fbc-4778-470c-9653-feb859a3418f 7 e-9
#> 8 fleischerei-stiefsohn_00000005219477-001 all high 0.697 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 7c7718bb-2372-5d04-a7ac-1ae5b12b05e3_61396bcb-bf35-411a-a6a6-85e8 1.04e+0
#> 9 fleischerei-stiefsohn_00000005219477-001 input_isic_4digit high 0.857 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5 7.07e+0
#> 10 fleischerei-stiefsohn_00000005219477-001 input_isic_4digit high 1 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa 1aeb18b9-8355-560f-82aa-543c771c4d61_a0e53510-b90b-43ba-80cc-7600f5d 3.99e+1
#> # ℹ 309 more rows
companies <- read_csv(toy_sector_profile_companies())
scenarios <- read_csv(toy_sector_profile_any_scenarios())
sector_profile(companies, scenarios) |> unnest_product()
#> # A tibble: 196 × 11
#> companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid tilt_sector scenario year type tilt_subsector
#> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 fleischerei-stiefsohn_00000005219477-001 ipr_1.5c rps_2030 high 0.23 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> 1.5c rps 2030 ipr <NA>
#> 2 fleischerei-stiefsohn_00000005219477-001 ipr_1.5c rps_2050 high 0.96 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> 1.5c rps 2050 ipr <NA>
#> 3 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2020 low 0 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> stated policies scenario 2020 weo <NA>
#> 4 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2020 low 0 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> announced pledges scenario 2020 weo <NA>
#> 5 fleischerei-stiefsohn_00000005219477-001 weo_net zero emissions by 2050 scenario_2020 low 0 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> net zero emissions by 2050 scenario 2020 weo <NA>
#> 6 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2030 low -0.0752 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> stated policies scenario 2030 weo <NA>
#> 7 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2030 low 0.0781 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> announced pledges scenario 2030 weo <NA>
#> 8 fleischerei-stiefsohn_00000005219477-001 weo_net zero emissions by 2050 scenario_2030 high 0.233 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> net zero emissions by 2050 scenario 2030 weo <NA>
#> 9 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2040 low -0.0270 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> stated policies scenario 2040 weo <NA>
#> 10 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2040 medium 0.336 steel 0faa7ecb-fef2-5117-8993-387c1236-001e-49b5-aa3d-810c0214f9ce <NA> announced pledges scenario 2040 weo <NA>
#> # ℹ 186 more rows
companies <- read_csv(toy_sector_profile_upstream_companies())
scenarios <- read_csv(toy_sector_profile_any_scenarios())
inputs <- read_csv(toy_sector_profile_upstream_products())
sector_profile_upstream(companies, scenarios, inputs) |> unnest_product()
#> # A tibble: 704 × 13
#> companies_id grouped_by risk_category profile_ranking clustered activity_uuid_product_uuid tilt_sector scenario year type input_activity_uuid_product_uuid input_tilt_sector input_tilt_subsector
#> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr>
#> 1 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2020 low 0 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy stated policies scenario 2020 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 2 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2030 low -0.192 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy stated policies scenario 2030 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 3 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2040 low -0.517 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy stated policies scenario 2040 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 4 fleischerei-stiefsohn_00000005219477-001 weo_stated policies scenario_2050 low -0.689 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy stated policies scenario 2050 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 5 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2020 low 0 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy announced pledges scenario 2020 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 6 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2030 high 0.301 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy announced pledges scenario 2030 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 7 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2040 high 1.83 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy announced pledges scenario 2040 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 8 fleischerei-stiefsohn_00000005219477-001 weo_announced pledges scenario_2050 high 3.17 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy announced pledges scenario 2050 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 9 fleischerei-stiefsohn_00000005219477-001 weo_net zero emissions by 2050 scenario_2020 low 0 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy net zero emissions by 2050 scenario 2020 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> 10 fleischerei-stiefsohn_00000005219477-001 weo_net zero emissions by 2050 scenario_2030 high 0.909 stove 0a242b09-772a-5edf-8e82-9cb4ba52a258_ae39ee61-d4d0-4cce-93b4-0745344da5fa energy net zero emissions by 2050 scenario 2030 weo 5de8c337-dea9-5c1f-9d90-002de27188be_8911bd8c-a96f-4440-9f8e-a7dacf5e79de non-metallic minerals raw minerals
#> # ℹ 694 more rowsCreated on 2023-11-16 with reprex v2.0.2 |
Closes #549
Closes #581
This PR adds the column
profile_rankingto all outputs at product level. At company level I believe it makes no sense, since the values ofprofile_rankingare more granular (@AnneSchoenauer please confirm).TODO
EXCEPTIONS
Slide here any item that you intentionally choose to not do.
Include a unit test. Note the existing tests "outputs expected columns at product level". They already test that the output has columns that ultimately come from the same function:
cols_at_product_level().reprex
Created on 2023-11-14 with reprex v2.0.2