Closed QianFeng2020 closed 4 years ago
@QianFeng2020 this issue is resolved in the dev version of .data
and .match
.
You can install the latest versions using:
devtools::install_github("2DegreesInvesting/r2dii.data")
and
devtools::install_github("2DegreesInvesting/r2dii.match")
We're aiming to push these changes to CRAN this week or next.
Thanks!
Basically if you are using the stable CRAN release, everything should play well together, if you're using the dev version of any one package, there will likely be some instabilities.
The following reprex shows that both versions of region_isos can be used without error in the current dev versions of the packages (note: using the region_isos
file with demo data will yield a 0-row tibble since the region definitions won't link to the scenario)
Closing this issue now.
library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
valid_matches <- match_name(loanbook_demo, ald_demo) %>%
# WARNING: Remember to validate matches (see `?prioritize`)
prioritize()
names(region_isos_demo)
#> [1] "region" "isos" "source"
names(region_isos)
#> [1] "region" "isos" "source"
valid_matches %>%
join_ald_scenario(
ald = ald_demo,
scenario = scenario_demo_2020,
region_isos = region_isos_demo
)
#> # A tibble: 9,945 x 44
#> id_loan id_direct_loant… name_direct_loa… id_intermediate… name_intermedia…
#> <chr> <chr> <chr> <chr> <chr>
#> 1 L151 C168 Shaanxi Auto <NA> <NA>
#> 2 L151 C168 Shaanxi Auto <NA> <NA>
#> 3 L151 C168 Shaanxi Auto <NA> <NA>
#> 4 L151 C168 Shaanxi Auto <NA> <NA>
#> 5 L151 C168 Shaanxi Auto <NA> <NA>
#> 6 L151 C168 Shaanxi Auto <NA> <NA>
#> 7 L151 C168 Shaanxi Auto <NA> <NA>
#> 8 L151 C168 Shaanxi Auto <NA> <NA>
#> 9 L151 C168 Shaanxi Auto <NA> <NA>
#> 10 L151 C168 Shaanxi Auto <NA> <NA>
#> # … with 9,935 more rows, and 39 more variables: id_ultimate_parent <chr>,
#> # name_ultimate_parent <chr>, loan_size_outstanding <dbl>,
#> # loan_size_outstanding_currency <chr>, loan_size_credit_limit <dbl>,
#> # loan_size_credit_limit_currency <chr>, sector_classification_system <chr>,
#> # sector_classification_input_type <chr>,
#> # sector_classification_direct_loantaker <dbl>, fi_type <chr>,
#> # flag_project_finance_loan <chr>, name_project <lgl>,
#> # lei_direct_loantaker <lgl>, isin_direct_loantaker <lgl>, id_2dii <chr>,
#> # level <chr>, sector <chr>, sector_ald <chr>, name <chr>, name_ald <chr>,
#> # score <dbl>, source <chr>, technology <chr>, production_unit <chr>,
#> # year <int>, production <dbl>, emission_factor <dbl>,
#> # country_of_domicile <chr>, plant_location <chr>, number_of_assets <int>,
#> # is_ultimate_owner <lgl>, is_ultimate_listed_owner <lgl>,
#> # ald_timestamp <chr>, ald_emission_factor_unit <chr>, scenario <chr>,
#> # region <chr>, tmsr <dbl>, smsp <dbl>, scenario_source <chr>
valid_matches %>%
join_ald_scenario(
ald = ald_demo,
scenario = scenario_demo_2020,
region_isos = region_isos
)
#> # A tibble: 0 x 44
#> # … with 44 variables: id_loan <chr>, id_direct_loantaker <chr>,
#> # name_direct_loantaker <chr>, id_intermediate_parent_1 <chr>,
#> # name_intermediate_parent_1 <chr>, id_ultimate_parent <chr>,
#> # name_ultimate_parent <chr>, loan_size_outstanding <dbl>,
#> # loan_size_outstanding_currency <chr>, loan_size_credit_limit <dbl>,
#> # loan_size_credit_limit_currency <chr>, sector_classification_system <chr>,
#> # sector_classification_input_type <chr>,
#> # sector_classification_direct_loantaker <dbl>, fi_type <chr>,
#> # flag_project_finance_loan <chr>, name_project <lgl>,
#> # lei_direct_loantaker <lgl>, isin_direct_loantaker <lgl>, id_2dii <chr>,
#> # level <chr>, sector <chr>, sector_ald <chr>, name <chr>, name_ald <chr>,
#> # score <dbl>, source <chr>, technology <chr>, production_unit <chr>,
#> # year <int>, production <dbl>, emission_factor <dbl>,
#> # country_of_domicile <chr>, plant_location <chr>, number_of_assets <int>,
#> # is_ultimate_owner <lgl>, is_ultimate_listed_owner <lgl>,
#> # ald_timestamp <chr>, ald_emission_factor_unit <chr>, scenario <chr>,
#> # region <chr>, tmsr <dbl>, smsp <dbl>, scenario_source <chr>
Created on 2020-05-27 by the reprex package (v0.3.0)
couldn't find "region_isos_demo" in r2dii.data or r2dii.dataraw. The dataset "region_isos" does not have the column "scenario_source" and it reports an error when running "join_ald_scenario".