-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
160 lines (117 loc) · 4.01 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tiltPlot
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/2DegreesInvesting/tiltPlot/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/2DegreesInvesting/tiltPlot/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/2DegreesInvesting/tiltPlot/branch/main/graph/badge.svg)](https://app.codecov.io/gh/2DegreesInvesting/tiltPlot?branch=main)
<!-- badges: end -->
The goal of tiltPlot is to provide plots for the TILT project.
## Installation
You can install the development version of tiltPlot from GitHub with:
```r
# install.packages("pak")
pak::pak("2DegreesInvesting/tiltPlot")
```
## Example
```{r}
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(tiltPlot)
```
### 1. Sankey Plot with financial data
```{r}
financial
```
```{r}
fin <- financial
benchmark <- "tilt_sector"
mode <- "equal_weight"
plot_sankey(fin, with_company = TRUE, benchmark = "tilt_sector", mode = "equal_weight") +
ggtitle(
"Sankey Plot",
paste("Stratified by the amount of loan by the bank, with the", mode, "mode", "and benchmark", benchmark)
)
```
You can also choose to have the plot without the company node.
```{r}
plot_sankey(fin, with_company = FALSE, benchmark = "tilt_sector", mode = "equal_weight")
```
Finally, the user can choose different modes to plot the Sankey plot with financial data available.
```{r}
plot_sankey(fin, with_company = FALSE, benchmark = "tilt_sector", mode = "best_case")
```
### 2. Emission profile plots with financial data
```{r}
financial
```
On a company level:
```{r}
fin <- financial
benchmarks <- c("all", "unit")
fin |>
filter(company_name == "tilman") |>
bar_plot_emission_profile_financial(benchmarks, mode = "equal_weight") +
labs(title = "Emission profile of all products on a company level, on an equal
weight financial mode")
```
On a portfolio level:
```{r}
bar_plot_emission_profile_financial(fin, benchmarks, mode = "equal_weight") +
labs(title = "Emission profile of all products on a portfolio level, on an equal
weight financial mode")
```
### 3. Emission profile plots without financial data
```{r}
without_financial
```
Plot on a company level.
The user can choose any number of benchmark to be plotted.
```{r}
no_fin <- without_financial
benchmarks <- c("unit", "unit_tilt_sector")
company_name <- no_fin$companies_id[1]
no_fin |>
filter(companies_id == company_name) |>
bar_plot_emission_profile(benchmarks, mode = "equal_weight", scenario = "1.5C RPS", year = 2030) +
labs(title = "Emission profile of all products on a company level")
```
Plot on a portfolio level.
```{r}
bar_plot_emission_profile(no_fin, benchmarks, mode = "equal_weight", scenario = "1.5C RPS", year = 2030) +
labs(title = "Emission profile of all products on a portfolio level")
```
### 4. Scatter plot of the emission profiles and transition risk scores, with financial data
```{r}
fin <- financial
scenario <- "IPR"
year <- 2030
benchmarks <- c("all", "unit")
mode <- "best_case"
scatter_plot_financial(fin,
benchmarks = benchmarks,
mode = mode,
scenario = scenario,
year = year
)
```
### 5. Create a German map with risk categories color gradient, without financial
Different modes can be chosen: "equal_weight", "worst_case" and "best_case".
If nothing is chosen, equal_weight the default mode.
```{r}
no_fin <- without_financial
map_region_risk(no_fin, "DE", benchmark = "unit_tilt_sector", mode = "worst_case", scenario = "NZ 2050", year = 2030) +
labs(title = "German map of high, medium and low proportions of the companies
that are found in one region.
© EuroGeographics for the administrative boundaries ")
```