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_sda outputs unexpected NAs #307

Closed
jdhoffa opened this issue Jun 8, 2021 · 0 comments · Fixed by #309
Closed

target_sda outputs unexpected NAs #307

jdhoffa opened this issue Jun 8, 2021 · 0 comments · Fixed by #309
Labels
bug an unexpected problem or unintended behavior medium Likely finished in under a week

Comments

@jdhoffa
Copy link
Member

jdhoffa commented Jun 8, 2021

There are two big issues exposed in the reprex below.

  • target_sda should only output values in the range of years presented in the co2_scenario input.
  • target_sda should not output a value for target_NA (which seems to be a scenario defined as NA?)

Brief description of the problem

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)

# ald with only sectors that we have CO2 scenarios for
ald <- head(ald_demo, 100) %>% 
  filter(sector %in% c("cement", "steel"))

matched<- prioritize(match_name(loanbook_demo, ald))

co2_scenario <- co2_intensity_scenario_demo

out <- target_sda(matched, ald, co2_scenario) 

out_targets <- out %>% 
  filter(!(emission_factor_metric %in% c("projected", "corporate_economy")))

# all targets before 2020 are NA
out_targets %>% 
  filter(year < 2020)
#> # A tibble: 14 x 4
#>    sector  year emission_factor_metric emission_factor_value
#>    <chr>  <dbl> <chr>                                  <dbl>
#>  1 cement  2013 target_NA                                 NA
#>  2 cement  2013 target_demo                               NA
#>  3 cement  2014 target_NA                                 NA
#>  4 cement  2014 target_demo                               NA
#>  5 cement  2015 target_NA                                 NA
#>  6 cement  2015 target_demo                               NA
#>  7 cement  2016 target_NA                                 NA
#>  8 cement  2016 target_demo                               NA
#>  9 cement  2017 target_NA                                 NA
#> 10 cement  2017 target_demo                               NA
#> 11 cement  2018 target_NA                                 NA
#> 12 cement  2018 target_demo                               NA
#> 13 cement  2019 target_NA                                 NA
#> 14 cement  2019 target_demo                               NA

# some targets after 2020 are NA
out_targets %>% 
  filter(year >= 2020)
#> # A tibble: 93 x 4
#>    sector  year emission_factor_metric emission_factor_value
#>    <chr>  <dbl> <chr>                                  <dbl>
#>  1 cement  2020 target_NA                             NA    
#>  2 cement  2020 target_demo                            0.723
#>  3 cement  2021 target_NA                             NA    
#>  4 cement  2021 target_demo                            0.660
#>  5 cement  2022 target_NA                             NA    
#>  6 cement  2022 target_demo                            0.597
#>  7 cement  2023 target_NA                             NA    
#>  8 cement  2023 target_demo                            0.534
#>  9 cement  2024 target_NA                             NA    
#> 10 cement  2024 target_demo                            0.471
#> # … with 83 more rows

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

@jdhoffa jdhoffa added bug an unexpected problem or unintended behavior medium Likely finished in under a week on-ADO labels Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior medium Likely finished in under a week
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant