Skip to content
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

grouped_by now refers to names in "co2" #601

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

maurolepore
Copy link
Contributor

@maurolepore maurolepore commented Nov 12, 2023

Relates to #566

This PR makes a change necessary to export emissions_profile_any_add_values_to_categorize() as a pre-processing helper (#596).

The values of grouped_by are now more transparent and less surprising (see related principle) (#601). They now simply refer to the full name of the corresponding columns in
the "co2" dataset (products or inputs) passed to the emissions_profile*()
functions. For example, passing a column products$tilt_sector now yields the
value "tilt_sector" in group_by -- which before was obscurely renamed to "tilt_sec".

BEFORE

devtools::load_all()
#> ℹ Loading tiltIndicator
packageVersion("tiltIndicator")
#> [1] '0.0.0.9094'

products <- example_products()
products
#> # A tibble: 1 × 5
#>   activity_uuid_product_uuid tilt_sector unit  isic_4digit co2_footprint
#>   <chr>                      <chr>       <chr> <chr>       <chr>        
#> 1 a                          a           a     1234        1

products |> emissions_profile_any_add_values_to_categorize()
#> Error in `map()`:
#> ℹ In index: 2.
#> ℹ With name: isic_sec.
#> Caused by error in `all_of()`:
#> ! Can't subset columns that don't exist.
#> ✖ Column `isic_sec` doesn't exist.

Created on 2023-11-12 with reprex v2.0.2

NOW

devtools::load_all()
#> ℹ Loading tiltIndicator
packageVersion("tiltIndicator")
#> [1] '0.0.0.9095'

products <- example_products()
products
#> # A tibble: 1 × 5
#>   activity_uuid_product_uuid tilt_sector unit  isic_4digit co2_footprint
#>   <chr>                      <chr>       <chr> <chr>       <chr>        
#> 1 a                          a           a     1234        1

products |> emissions_profile_any_add_values_to_categorize()
#> # A tibble: 6 × 7
#>   grouped_by  activity_uuid_produc…¹ tilt_sector unit  isic_4digit co2_footprint
#>   <chr>       <chr>                  <chr>       <chr> <chr>       <chr>        
#> 1 all         a                      a           a     1234        1            
#> 2 isic_4digit a                      a           a     1234        1            
#> 3 tilt_sector a                      a           a     1234        1            
#> 4 unit        a                      a           a     1234        1            
#> 5 unit_isic_… a                      a           a     1234        1            
#> 6 unit_tilt_… a                      a           a     1234        1            
#> # ℹ abbreviated name: ¹​activity_uuid_product_uuid
#> # ℹ 1 more variable: values_to_categorize <dbl>

Created on 2023-11-12 with reprex v2.0.2


TODO

  • Link related issue/PR.
  • Describe the goal of the PR. Avoid details that are clear in the diff.
  • Mark the PR as draft.
  • Include a unit test.
  • Review your own PR in "Files changed".
  • Ensure the PR branch is updated.
  • Ensure the checks pass.
  • Change the status from draft to ready.
  • Polish the PR title and description.

EXCEPTIONS

  • Slide here any item that you intentionally choose to not do.
  • Assign a reviewer.

Sorry, something went wrong.

@maurolepore maurolepore force-pushed the Refactor-work-with-generic-benchmarks branch from f319dff to d6b502d Compare November 12, 2023 08:05
@maurolepore maurolepore marked this pull request as ready for review November 12, 2023 08:08
@maurolepore maurolepore changed the title grouped_by now refers to the benchmarks by their name in "co2" grouped_by now refers to names in "co2" Nov 12, 2023
@maurolepore maurolepore merged commit 6e68854 into main Nov 12, 2023
@maurolepore maurolepore deleted the Refactor-work-with-generic-benchmarks branch November 12, 2023 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant