You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
currently, check_unique_id() only used in target_sda(), not in target_market_share()
is this desired? in workflow.aggregate.loanbook, it does not seem to cause issues to have multiple identical loan_ids in the target_market_share calculation...
The reprex highlights that this can be an issue in target_market_share when two loans have the same id but otherwise differ.
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)
loanbook<-loanbook_demo[1:3, ]
matched<-loanbook|>
match_name(abcd_demo) |>
prioritize()
# duplicate loans with diff valuesmatched_duplicate_diff<-matchedmatched_duplicate_diff$loan_size_outstanding<-1matched_duplicate_diff<- rbind(matched, matched_duplicate_diff)
# duplicate the exact same loansmatched_duplicate_same<- rbind(matched, matched)
matched$id_loan#> [1] "L1" "L3"matched_duplicate_diff$id_loan#> [1] "L1" "L3" "L1" "L3"matched_duplicate_same$id_loan#> [1] "L1" "L3" "L1" "L3"result_tms<-matched|>
target_market_share(abcd_demo, scenario_demo_2020, region_isos_demo)
result_duplicate_diff_tms<-matched_duplicate_diff|>
target_market_share(abcd_demo, scenario_demo_2020, region_isos_demo)
result_duplicate_same_tms<-matched_duplicate_same|>
target_market_share(abcd_demo, scenario_demo_2020, region_isos_demo)
all.equal(result_tms, result_duplicate_diff_tms)
#> [1] "Component \"production\": Mean relative difference: 7.422493e-07" #> [2] "Component \"technology_share\": Mean relative difference: 9.133179e-07" #> [3] "Component \"percentage_of_initial_production_by_scope\": Mean relative difference: 2.605609e-08"
all.equal(result_tms, result_duplicate_same_tms)
#> [1] TRUE
all.equal(result_duplicate_same_tms, result_duplicate_diff_tms)
#> [1] "Component \"production\": Mean relative difference: 7.422493e-07" #> [2] "Component \"technology_share\": Mean relative difference: 9.133179e-07" #> [3] "Component \"percentage_of_initial_production_by_scope\": Mean relative difference: 2.605609e-08"result_sda<-matched|>
target_sda(abcd_demo, co2_intensity_scenario_demo, region_isos=region_isos_demo)
#> Warning: Removing rows in abcd where `emission_factor` is NA#> Warning: Found no match between loanbook and abcd.result_duplicate_sda<-matched_duplicate|>
target_sda(abcd_demo, co2_intensity_scenario_demo, region_isos=region_isos_demo)
#> Error in eval(expr, envir, enclos): object 'matched_duplicate' not found
depending on whether we expected that this check should be available, this could be marked a bug. in any case I think this should be a priority, because prcessing multiple loan books makes us more prone to such situations
r2dii.analysis/R/target_sda.R
Line 100 in 53a1ed3
currently,
check_unique_id()
only used intarget_sda()
, not intarget_market_share()
is this desired? in
workflow.aggregate.loanbook
, it does not seem to cause issues to have multiple identicalloan_ids
in the target_market_share calculation...The reprex highlights that this can be an issue in
target_market_share
when two loans have the same id but otherwise differ.Created on 2024-04-19 with reprex v2.1.0
AB#10681
The text was updated successfully, but these errors were encountered: