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

target_market_share should only output sectors that input portfolio is exposed to #329

Closed
jdhoffa opened this issue Jul 6, 2021 · 0 comments · Fixed by #332
Closed

target_market_share should only output sectors that input portfolio is exposed to #329

jdhoffa opened this issue Jul 6, 2021 · 0 comments · Fixed by #332

Comments

@jdhoffa
Copy link
Member

jdhoffa commented Jul 6, 2021

If the input portfolio, for example, only contains companies that operate in the power sector, the output should only contain data in the power sector.

Currently, the corporate_economy output contains all sectors. See reprex:

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.analysis)

# a dummy matched file, with only one company in it
matched <- tibble::tribble(
  ~id_loan, ~id_direct_loantaker,                    ~name_direct_loantaker, ~id_intermediate_parent_1, ~name_intermediate_parent_1, ~id_ultimate_parent,             ~name_ultimate_parent, ~loan_size_outstanding, ~loan_size_outstanding_currency, ~loan_size_credit_limit, ~loan_size_credit_limit_currency, ~sector_classification_system, ~sector_classification_input_type, ~sector_classification_direct_loantaker, ~fi_type, ~flag_project_finance_loan, ~name_project, ~lei_direct_loantaker, ~isin_direct_loantaker, ~id_2dii,            ~level, ~sector, ~sector_ald,                             ~name,                         ~name_ald, ~score,    ~source, ~borderline,
  "L11",               "C309", "Yuxi ounty Liuan dropower elopment C. L",                        NA,                          NA,              "UP81", "Dynegy Midwest Generation, Inc.",                 191289,                           "EUR",                18626259,                            "EUR",                        "NACE",                            "Code",                                    3511,   "Loan",                       "No",            NA,                    NA,                     NA,   "UP81", "ultimate_parent", "power",     "power", "Dynegy Midwest Generation, Inc.", "dynegy midwest generation, inc.",      1, "loanbook",       FALSE
)

# this company is only exposed to coal (power sector)
ald_demo %>% 
  filter(
    name_company == "dynegy midwest generation, inc."
  ) %>% 
  select(technology) %>% 
  unique()
#> # A tibble: 1 x 1
#>   technology
#>   <chr>     
#> 1 coalcap

# Adding "green" technologies
out <- matched %>% 
  target_market_share(
    ald_demo, 
    scenario_demo_2020,
    region_isos_demo
  )

# output should only show power sector results
out %>% 
  select(sector) %>% 
  unique()
#> # A tibble: 9 x 1
#>   sector     
#>   <chr>      
#> 1 power      
#> 2 automotive 
#> 3 aviation   
#> 4 cement     
#> 5 coal       
#> 6 hdv        
#> 7 oil and gas
#> 8 shipping   
#> 9 steel

Created on 2021-07-06 by the reprex package (v2.0.0)

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 a pull request may close this issue.

1 participant