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

257 minimal demo data lbk and abcd #374

Merged
merged 5 commits into from
Apr 24, 2024
Merged

Conversation

jacobvjk
Copy link
Member

@jacobvjk jacobvjk commented Apr 18, 2024

closes #257
closes #372

  • abcd_demo drops columns abcd_timestamp (not needed for calculation) and country_of_domicile (not part of the P4B format ABCD)
  • loanbook_demo drops columns id_intermediate_parent_1, name_intermediate_parent_1,, sector_classification_input_type, fi_type, flag_project_finance_loan, and name_project, none of which are needed for the calculation
  • data_dictionary is adjusted accordingly and drops the mention of these variables
  • snaps are updated

NOTE:

  • we may want to keep the variables that were removed from the demo data sets in the data_dictionary. If so, test expectations need to be adjusted

The new demo data sets generate the following demo output

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
library(r2dii.plot)

names(loanbook_demo)
#>  [1] "id_loan"                               
#>  [2] "id_direct_loantaker"                   
#>  [3] "name_direct_loantaker"                 
#>  [4] "id_ultimate_parent"                    
#>  [5] "name_ultimate_parent"                  
#>  [6] "loan_size_outstanding"                 
#>  [7] "loan_size_outstanding_currency"        
#>  [8] "loan_size_credit_limit"                
#>  [9] "loan_size_credit_limit_currency"       
#> [10] "sector_classification_system"          
#> [11] "sector_classification_direct_loantaker"
#> [12] "lei_direct_loantaker"                  
#> [13] "isin_direct_loantaker"
# "lei_direct_loantaker" is optional, but may be used as a `join_id`
# "isin_direct_loantaker" is optional, but may be used as a `join_id`

names(abcd_demo)
#>  [1] "company_id"           "name_company"         "lei"                 
#>  [4] "sector"               "technology"           "production_unit"     
#>  [7] "year"                 "production"           "emission_factor"     
#> [10] "plant_location"       "is_ultimate_owner"    "emission_factor_unit"

matched <- loanbook_demo |> 
  match_name(abcd_demo) |> 
  prioritize()

matched |> 
  target_market_share(abcd_demo, scenario_demo_2020, region_isos_demo) |> 
  filter(sector == "power", region == "global", technology == "renewablescap") |> 
  prep_trajectory() |> 
  plot_trajectory()

matched |> 
  target_sda(
    abcd_demo, 
    co2_intensity_scenario_demo, 
    region_isos = region_isos_demo
  ) |> 
  filter(sector == "cement", region == "global") |> 
  prep_emission_intensity() |> 
  plot_emission_intensity()
#> Warning: Removing rows in abcd where `emission_factor` is NA

Created on 2024-04-18 with reprex v2.1.0

@jacobvjk jacobvjk changed the title 257 minimal loanbook demo 257 minimal demo data lbk and abcd Apr 18, 2024
@jacobvjk jacobvjk requested a review from jdhoffa April 18, 2024 13:44
@jdhoffa
Copy link
Member

jdhoffa commented Apr 18, 2024

Just noting that:
loanbook_demo drops columns id_intermediate_parent_1, name_intermediate_parent_1 MIGHT affect some downstream vignettes in r2dii.match... not certain atm, but make sure to be cautious there.

Otherwise LGTM

@jacobvjk jacobvjk marked this pull request as ready for review April 22, 2024 10:57
@jacobvjk
Copy link
Member Author

to feel safe about this, I would appreciate you checking the r2dii.match vignettes as well @jdhoffa in case you find time for that

@jacobvjk jacobvjk requested a review from jdhoffa April 22, 2024 10:58
@jdhoffa
Copy link
Member

jdhoffa commented Apr 23, 2024

Testing now!

Copy link
Member

@jdhoffa jdhoffa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
I saw no issues when testing against this PR: RMI-PACTA/r2dii.match#473

@jacobvjk jacobvjk merged commit 46cf42e into main Apr 24, 2024
22 checks passed
@jacobvjk jacobvjk deleted the 257-minimal-loanbook-demo branch April 24, 2024 07:58
jdhoffa added a commit to RMI-PACTA/r2dii.match that referenced this pull request Apr 25, 2024
The (brittle) snapshot tests are currently failing when run against the CRAN published `r2dii.data v0.5.0`. They only pass against the dev version of the package.

This PR bumps the function that skips snapshot tests with old `r2dii.data`. 

Another indication that we should prioritize working on #392

Relates to RMI-PACTA/r2dii.data#374
Relates to #473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants