Skip to content

Commit

Permalink
Merge pull request #447 from RMI-PACTA/release/0.3.0
Browse files Browse the repository at this point in the history
Release/0.3.0
  • Loading branch information
AlexAxthelm authored Oct 17, 2023
2 parents 66f02b7 + a41dfe5 commit a068675
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
docs
revdep/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: r2dii.analysis
Title: Measure Climate Scenario Alignment of Corporate Loans
Version: 0.2.1.9000
Version: 0.3.0
Authors@R:
c(person(given = "Alex",
family = "Axthelm",
Expand Down Expand Up @@ -48,7 +48,7 @@ Imports:
glue,
lifecycle,
magrittr,
r2dii.data,
r2dii.data (>= 0.4.0),
rlang (>= 0.1.2),
tidyr,
tidyselect,
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# r2dii.analysis (development version)
# r2dii.analysis 0.3.0

# `target_sda` now uses final year of scenario as convergence target when `by_company = TRUE` (#445).
# `target_market_share` gains argument `increasing_or_decreasing` (#426).
Expand Down
3 changes: 2 additions & 1 deletion R/summarize_weighted_production.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
#' abcd = abcd,
#' scenario = scenario_demo_2020,
#' region_isos = region_isos_demo
#' )
#' ) %>%
#' dplyr::filter(production != 0)
#'
#' summarize_weighted_production(master)
#'
Expand Down
2 changes: 1 addition & 1 deletion R/target_sda.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ compute_loanbook_targets <- function(data,
data <- data %>%
group_by(!!!rlang::syms(...)) %>%
arrange(.data$year) %>%
tidyr::complete(.data$name_abcd, year) %>%
tidyr::complete(.data$name_abcd, .data$year) %>%
ungroup() %>%
select(-all_of(c("emission_factor_adjusted_scenario", "p"))) %>%
right_join(
Expand Down
162 changes: 81 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ climate goals. They summarize key metrics attributed to the portfolio
(e.g. production, emission factors), and calculate targets based on
climate scenarios. They implement in R the last step of the free
software ‘PACTA’ (Paris Agreement Capital Transition Assessment;
<https://www.transitionmonitor.com/>). Financial institutions use ‘PACTA’ to
study how their capital allocation impacts the climate.
<https://www.transitionmonitor.com/>). Financial institutions use
‘PACTA’ to study how their capital allocation impacts the climate.

## Installation

Expand Down Expand Up @@ -73,21 +73,21 @@ matched %>%
region_isos = region_isos_demo
)
#> Warning: Removing rows in abcd where `emission_factor` is NA
#> # A tibble: 166 × 6
#> sector year region scenario_source emission_factor_met…¹ emiss…²
#> <chr> <dbl> <chr> <chr> <chr> <dbl>
#> 1 cement 2013 advanced economies demo_2020 projected 0.0217
#> 2 cement 2013 developing asia demo_2020 projected 0.0606
#> 3 cement 2013 global demo_2020 projected 0.658
#> 4 cement 2014 advanced economies demo_2020 projected 0.0219
#> 5 cement 2014 developing asia demo_2020 projected 0.0604
#> 6 cement 2014 global demo_2020 projected 0.659
#> 7 cement 2015 advanced economies demo_2020 projected 0.0221
#> 8 cement 2015 developing asia demo_2020 projected 0.0603
#> 9 cement 2015 global demo_2020 projected 0.660
#> 10 cement 2016 advanced economies demo_2020 projected 0.0223
#> # … with 156 more rows, and abbreviated variable names ¹​emission_factor_metric,
#> # ²​emission_factor_value
#> # A tibble: 96 × 6
#> sector year region scenario_source emission_factor_metric
#> <chr> <dbl> <chr> <chr> <chr>
#> 1 steel 2021 advanced economies demo_2020 projected
#> 2 steel 2021 global demo_2020 projected
#> 3 steel 2022 advanced economies demo_2020 projected
#> 4 steel 2022 global demo_2020 projected
#> 5 steel 2024 advanced economies demo_2020 projected
#> 6 steel 2024 global demo_2020 projected
#> 7 steel 2025 advanced economies demo_2020 projected
#> 8 steel 2025 global demo_2020 projected
#> 9 steel 2027 advanced economies demo_2020 projected
#> 10 steel 2027 global demo_2020 projected
#> # ℹ 86 more rows
#> # ℹ 1 more variable: emission_factor_value <dbl>
```

- Use `target_market_share` to calculate market-share scenario targets
Expand All @@ -100,22 +100,22 @@ matched %>%
scenario = scenario_demo_2020,
region_isos = region_isos_demo
)
#> # A tibble: 1,790 × 10
#> sector techno…¹ year region scena…² metric produ…³ techn…⁴ scope perce…⁵
#> <chr> <chr> <int> <chr> <chr> <chr> <dbl> <dbl> <chr> <dbl>
#> 1 automotive electric 2020 global demo_2… proje… 324592. 0.0759 sect… 0
#> 2 automotive electric 2020 global demo_2… targe… 324592. 0.0759 sect… 0
#> 3 automotive electric 2020 global demo_2… targe… 324592. 0.0759 sect… 0
#> 4 automotive electric 2020 global demo_2… targe… 324592. 0.0759 sect… 0
#> 5 automotive electric 2021 global demo_2… proje… 339656. 0.0786 sect… 0.00352
#> 6 automotive electric 2021 global demo_2… targe… 329191. 0.0744 sect… 0.00108
#> 7 automotive electric 2021 global demo_2… targe… 352505. 0.0809 sect… 0.00653
#> 8 automotive electric 2021 global demo_2… targe… 330435. 0.0747 sect… 0.00137
#> 9 automotive electric 2022 global demo_2… proje… 354720. 0.0813 sect… 0.00705
#> 10 automotive electric 2022 global demo_2… targe… 333693. 0.0730 sect… 0.00213
#> # … with 1,780 more rows, and abbreviated variable names ¹​technology,
#> # ²​scenario_source, ³​production, ⁴​technology_share,
#> # ⁵​percentage_of_initial_production_by_scope
#> # A tibble: 1,232 × 10
#> sector technology year region scenario_source metric production
#> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl>
#> 1 automotive electric 2020 global demo_2020 projected 3664.
#> 2 automotive electric 2020 global demo_2020 target_cps 3664.
#> 3 automotive electric 2020 global demo_2020 target_sds 3664.
#> 4 automotive electric 2020 global demo_2020 target_sps 3664.
#> 5 automotive electric 2021 global demo_2020 projected 8472.
#> 6 automotive electric 2021 global demo_2020 target_cps 3845.
#> 7 automotive electric 2021 global demo_2020 target_sds 4766.
#> 8 automotive electric 2021 global demo_2020 target_sps 3894.
#> 9 automotive electric 2022 global demo_2020 projected 8436.
#> 10 automotive electric 2022 global demo_2020 target_cps 4023.
#> # ℹ 1,222 more rows
#> # ℹ 3 more variables: technology_share <dbl>, scope <chr>,
#> # percentage_of_initial_production_by_scope <dbl>
```

- Or at the company level:
Expand All @@ -132,23 +132,22 @@ matched %>%
#> This will result in company-level results, weighted by the portfolio
#> loan size, which is rarely useful. Did you mean to set one of these
#> arguments to `FALSE`?
#> # A tibble: 32,402 × 11
#> sector techno…¹ year region scena…² name_…³ metric produ…⁴ techn…⁵ scope
#> <chr> <chr> <int> <chr> <chr> <chr> <chr> <dbl> <dbl> <chr>
#> 1 automotive electric 2020 global demo_2… toyota… proje… 324592. 0.0759 sect…
#> 2 automotive electric 2020 global demo_2… toyota… targe… 324592. 0.0759 sect…
#> 3 automotive electric 2020 global demo_2… toyota… targe… 324592. 0.0759 sect…
#> 4 automotive electric 2020 global demo_2… toyota… targe… 324592. 0.0759 sect…
#> 5 automotive electric 2021 global demo_2… toyota… proje… 339656. 0.0786 sect…
#> 6 automotive electric 2021 global demo_2… toyota… targe… 329191. 0.0744 sect…
#> 7 automotive electric 2021 global demo_2… toyota… targe… 352505. 0.0809 sect…
#> 8 automotive electric 2021 global demo_2… toyota… targe… 330435. 0.0747 sect…
#> 9 automotive electric 2022 global demo_2… toyota… proje… 354720. 0.0813 sect…
#> 10 automotive electric 2022 global demo_2… toyota… targe… 333693. 0.0730 sect…
#> # … with 32,392 more rows, 1 more variable:
#> # percentage_of_initial_production_by_scope <dbl>, and abbreviated variable
#> # names ¹​technology, ²​scenario_source, ³​name_abcd, ⁴​production,
#> # ⁵​technology_share
#> # A tibble: 3,200 × 11
#> sector technology year region scenario_source name_abcd metric production
#> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl>
#> 1 automoti… electric 2020 global demo_2020 large au… proje… 713.
#> 2 automoti… electric 2020 global demo_2020 large au… targe… 713.
#> 3 automoti… electric 2020 global demo_2020 large au… targe… 713.
#> 4 automoti… electric 2020 global demo_2020 large au… targe… 713.
#> 5 automoti… electric 2020 global demo_2020 large au… proje… 535.
#> 6 automoti… electric 2020 global demo_2020 large au… targe… 535.
#> 7 automoti… electric 2020 global demo_2020 large au… targe… 535.
#> 8 automoti… electric 2020 global demo_2020 large au… targe… 535.
#> 9 automoti… electric 2020 global demo_2020 large au… proje… 690.
#> 10 automoti… electric 2020 global demo_2020 large au… targe… 690.
#> # ℹ 3,190 more rows
#> # ℹ 3 more variables: technology_share <dbl>, scope <chr>,
#> # percentage_of_initial_production_by_scope <dbl>
```

### Utility Functions
Expand All @@ -175,41 +174,42 @@ loanbook_joined_to_abcd_scenario <- matched %>%
# portfolio level
loanbook_joined_to_abcd_scenario %>%
summarize_weighted_production(scenario, tmsr, smsp, region)
#> # A tibble: 702 × 9
#> sector_abcd technology year scenario tmsr smsp region weighted…¹ weigh…²
#> <chr> <chr> <int> <chr> <dbl> <dbl> <chr> <dbl> <dbl>
#> 1 automotive electric 2020 cps 1 0 global 324592. 0.0380
#> 2 automotive electric 2020 sds 1 0 global 324592. 0.0380
#> 3 automotive electric 2020 sps 1 0 global 324592. 0.0380
#> 4 automotive electric 2021 cps 1.12 0.00108 global 339656. 0.0393
#> 5 automotive electric 2021 sds 1.16 0.00653 global 339656. 0.0393
#> 6 automotive electric 2021 sps 1.14 0.00137 global 339656. 0.0393
#> 7 automotive electric 2022 cps 1.24 0.00213 global 354720. 0.0406
#> 8 automotive electric 2022 sds 1.32 0.0131 global 354720. 0.0406
#> 9 automotive electric 2022 sps 1.29 0.00273 global 354720. 0.0406
#> 10 automotive electric 2023 cps 1.35 0.00316 global 369784. 0.0419
#> # … with 692 more rows, and abbreviated variable names ¹​weighted_production,
#> # ²​weighted_technology_share
#> # A tibble: 558 × 9
#> sector_abcd technology year scenario tmsr smsp region
#> <chr> <chr> <dbl> <chr> <dbl> <dbl> <chr>
#> 1 automotive electric 2020 cps 1 0 global
#> 2 automotive electric 2020 sds 1 0 global
#> 3 automotive electric 2020 sps 1 0 global
#> 4 automotive electric 2021 cps 1.12 0.00108 global
#> 5 automotive electric 2021 sds 1.16 0.00653 global
#> 6 automotive electric 2021 sps 1.14 0.00137 global
#> 7 automotive electric 2022 cps 1.24 0.00213 global
#> 8 automotive electric 2022 sds 1.32 0.0131 global
#> 9 automotive electric 2022 sps 1.29 0.00273 global
#> 10 automotive electric 2023 cps 1.35 0.00316 global
#> # ℹ 548 more rows
#> # ℹ 2 more variables: weighted_production <dbl>,
#> # weighted_technology_share <dbl>

# company level
loanbook_joined_to_abcd_scenario %>%
summarize_weighted_production(scenario, tmsr, smsp, region, name_abcd)
#> # A tibble: 9,036 × 10
#> sector_a…¹ techn…² year scena…³ tmsr smsp region name_…⁴ weigh…⁵ weigh…⁶
#> <chr> <chr> <int> <chr> <dbl> <dbl> <chr> <chr> <dbl> <dbl>
#> 1 automotive electr… 2020 cps 1 0 global toyota… 324592. 0.0380
#> 2 automotive electr… 2020 sds 1 0 global toyota… 324592. 0.0380
#> 3 automotive electr… 2020 sps 1 0 global toyota… 324592. 0.0380
#> 4 automotive electr… 2021 cps 1.12 0.00108 global toyota… 339656. 0.0393
#> 5 automotive electr… 2021 sds 1.16 0.00653 global toyota… 339656. 0.0393
#> 6 automotive electr… 2021 sps 1.14 0.00137 global toyota… 339656. 0.0393
#> 7 automotive electr… 2022 cps 1.24 0.00213 global toyota… 354720. 0.0406
#> 8 automotive electr… 2022 sds 1.32 0.0131 global toyota… 354720. 0.0406
#> 9 automotive electr… 2022 sps 1.29 0.00273 global toyota… 354720. 0.0406
#> 10 automotive electr… 2023 cps 1.35 0.00316 global toyota… 369784. 0.0419
#> # … with 9,026 more rows, and abbreviated variable names ¹​sector_abcd,
#> # ²​technology, ³​scenario, ⁴​name_abcd, ⁵​weighted_production,
#> # ⁶​weighted_technology_share
#> # A tibble: 1,953 × 10
#> sector_abcd technology year scenario tmsr smsp region name_abcd
#> <chr> <chr> <dbl> <chr> <dbl> <dbl> <chr> <chr>
#> 1 automotive electric 2020 cps 1 0 global large automotive co…
#> 2 automotive electric 2020 cps 1 0 global large automotive co…
#> 3 automotive electric 2020 cps 1 0 global large automotive co…
#> 4 automotive electric 2020 cps 1 0 global large hdv company t…
#> 5 automotive electric 2020 sds 1 0 global large automotive co…
#> 6 automotive electric 2020 sds 1 0 global large automotive co…
#> 7 automotive electric 2020 sds 1 0 global large automotive co…
#> 8 automotive electric 2020 sds 1 0 global large hdv company t…
#> 9 automotive electric 2020 sps 1 0 global large automotive co…
#> 10 automotive electric 2020 sps 1 0 global large automotive co…
#> # ℹ 1,943 more rows
#> # ℹ 2 more variables: weighted_production <dbl>,
#> # weighted_technology_share <dbl>
```

[Get
Expand Down
17 changes: 2 additions & 15 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
## Test environments

* ubuntu 20.04 (local), R-release
* ubuntu 18.04 (github actions), R 3.4, R 3.5, R-oldrel, R-release
* macOS-latest (github actions), R-release, R-devel
* windows-latest (github actions), R-release
* win-builder, R-devel, R-release

## R CMD check results

0 errors | 0 warnings | 0 notes

## revdepcheck results

We checked 1 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
0 errors | 0 warnings | 1 note

* We saw 0 new problems
* We failed to check 0 packages
* Maintainer changed to Alex Axthelm while Jackson Hoffart is on extended leave.
2 changes: 1 addition & 1 deletion man/r2dii.analysis-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/summarize_weighted_production.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a068675

Please sign in to comment.