Title: | Easily Install and Load PACTA for Banks Packages |
Version: | 0.1.1 |
Description: | PACTA (Paris Agreement Capital Transition Assessment) for Banks is a tool that allows banks to calculate the climate alignment of their corporate lending portfolios. This package is designed to make it easy to install and load multiple PACTA for Banks packages in a single step. It also provides thorough documentation - the PACTA for Banks cookbook at https://rmi-pacta.github.io/pacta.loanbook/articles/cookbook_overview.html - on how to run a PACTA for Banks analysis. This covers prerequisites for the analysis, the separate steps of running the analysis, the interpretation of PACTA for Banks results, and advanced use cases. |
License: | MIT + file LICENSE |
URL: | https://rmi-pacta.github.io/pacta.loanbook/, https://github.com/RMI-PACTA/pacta.loanbook |
BugReports: | https://github.com/RMI-PACTA/pacta.loanbook/issues |
Depends: | R (≥ 4.1) |
Imports: | cli, dplyr, ggrepel, magrittr, purrr, r2dii.analysis (≥ 0.5.1), r2dii.data (≥ 0.6.0), r2dii.match (≥ 0.4.1), r2dii.plot (≥ 0.5.2), rlang, rstudioapi, scales, tibble, tidyselect |
Suggests: | covr, DiagrammeR, ggplot2, gt (≥ 0.11.0), knitr (≥ 1.42), readr, readxl, rmarkdown (≥ 2.19), roxygen2 (≥ 4.1.0), spelling, testthat (≥ 3.2.2), tidyr, writexl |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.2 |
Config/Needs/website: | rmi-pacta/pacta.pkgdown.rmitemplate, rmarkdown |
Config/testthat/edition: | 3 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-06-23 12:01:00 UTC; cjrmi |
Author: | Jacob Kastl |
Maintainer: | Jacob Kastl <jacob.kastl@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-24 09:50:02 UTC |
pacta.loanbook: Easily Install and Load PACTA for Banks Packages
Description
PACTA (Paris Agreement Capital Transition Assessment) for Banks is a tool that allows banks to calculate the climate alignment of their corporate lending portfolios. This package is designed to make it easy to install and load multiple PACTA for Banks packages in a single step. It also provides thorough documentation - the PACTA for Banks cookbook at https://rmi-pacta.github.io/pacta.loanbook/articles/cookbook_overview.html - on how to run a PACTA for Banks analysis. This covers prerequisites for the analysis, the separate steps of running the analysis, the interpretation of PACTA for Banks results, and advanced use cases.
Author(s)
Maintainer: Jacob Kastl jacob.kastl@gmail.com (ORCID) [contractor]
Authors:
Jackson Hoffart jackson.hoffart@gmail.com (ORCID) [contractor]
CJ Yetman cj@cjyetman.com (ORCID) [contractor]
Other contributors:
RMI PACTA4banks@rmi.org (03anfar33) [copyright holder, funder]
See Also
Useful links:
Report bugs at https://github.com/RMI-PACTA/pacta.loanbook/issues
An asset-based company dataset for demonstration
Description
Fake data about physical assets (e.g. wind turbine power plant capacities), aggregated to company-level. These data are used to assess the climate alignment of financial portfolios. It imitates data from market-intelligence databases.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
Usage
abcd_demo
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 4972 rows and 12 columns.
Definitions
-
company_id
(character): The id of the company owning the asset created by the data provider., *emission_factor
(double): Company level emission factor of the technology., *emission_factor_unit
(character): The units that the emission factor is measured in., *is_ultimate_owner
(logical): Flag if company is the ultimate parent in our database., *lei
(character): The legal entity identifier of the company owning the asset., *name_company
(character): The name of the company owning the asset., *plant_location
(character): Country where asset is located., *production
(double): Company level production of the technology., *production_unit
(character): The units that production is measured in., *sector
(character): Sector to which the asset belongs., *technology
(character): Technology implemented by the asset., *year
(integer): Year at which the production value is predicted.
See Also
Other demo data:
co2_intensity_scenario_demo
,
loanbook_demo
,
market_share_demo
,
overwrite_demo
,
region_isos_demo
,
scenario_demo_2020
,
sda_demo
Examples
head(abcd_demo)
A prepared CO2 intensity climate scenario dataset for demonstration
Description
Fake CO2 intensity climate scenario dataset, prepared for the software PACTA (Paris Agreement Capital Transition Assessment). It imitates climate scenario data (e.g. from the International Energy Agency (IEA)) including the change through time in production across industrial sectors.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
Usage
co2_intensity_scenario_demo
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 22 rows and 7 columns.
Definitions
-
emission_factor
(double): The target sector level emissions factor that the scenario prescribes., *emission_factor_unit
(character): The units that the emissions factor is measured in., *region
(character): The region to which the pathway is relevant., *scenario
(character): The name of the scenario., *scenario_source
(character): The source publication from which the scenario was taken., *sector
(character): The sector to which the scenario prescribes a pathway., *year
(integer): The year at which the pathway value is prescribed.
See Also
Other demo data:
abcd_demo
,
loanbook_demo
,
market_share_demo
,
overwrite_demo
,
region_isos_demo
,
scenario_demo_2020
,
sda_demo
Examples
head(co2_intensity_scenario_demo)
Crucial loanbook
columns for match_name()
Description
This is a helper to select the minimum loanbook
columns you need to run
match_name()
. Using more columns may use too much time and memory.
Usage
crucial_lbk()
Value
A character vector.
See Also
Other matching functions:
match_name()
,
prioritize()
,
prioritize_level()
Examples
crucial_lbk()
Data Dictionary
Description
A table of column names and descriptions of data frames used or exported by the functions in this package.
Usage
data_dictionary
Format
data_dictionary
- dataset
Name of the dataset
- column
Name of the column
- typeof
Type of the column
- definition
Definition of the column
Examples
data_dictionary
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
gics_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 282 rows and 5 columns.
Definitions
-
borderline
(logical): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope.., *code
(character): Original GICS code., *description
(character): Original GICS description., *sector
(character): Associated PACTA sector., *version
(character): Column identifying to which GICS version the code belongs.
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(gics_classification)
Determine if a technology is increasing or decreasing
Description
This dataset provides a simple lookup table to determine if a technology is meant to increase or decrease to align with a scenario that predicts a less than 2 degree temperature rise.
Usage
increasing_or_decreasing
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 20 rows and 3 columns.
Definitions
-
increasing_or_decreasing
(character): If the technology is increasing or decreasing, as defined by the Paris-aligned IEA scenarios., *sector
(character): The sector to which the technology belongs., *technology
(character): The technology sub-category within the sector.
See Also
Other datasets:
gics_classification
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(increasing_or_decreasing)
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
isic_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 830 rows and 6 columns.
Definitions
-
borderline
(logical): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope.., *code
(character): ISIC Rev 5 code with top-level letter prepended., *description
(character): Original ISIC Rev 5 title., *original_code
(character): Original ISIC Rev 5 code., *revision
(character): Column identifying to which ISIC revision the code belongs.., *sector
(character): Associated PACTA sector.
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(isic_classification)
Countries and codes
Description
This dataset maps countries to codes.
For information about the ISO standard for country codes see https://www.iso.org/iso-3166-country-codes.html.
Usage
iso_codes
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 286 rows and 2 columns.
Definitions
-
country
(character): Country name., *country_iso
(character): Corresponding ISO code.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(iso_codes)
A loanbook dataset for demonstration
Description
Fake financial portfolio.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
Usage
loanbook_demo
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 283 rows and 13 columns.
Definitions
-
id_direct_loantaker
(character): Borrower identifier unique to each borrower/sector combination in loanbook., *id_loan
(character): Unique loan identifier., *id_ultimate_parent
(character): Ultimate parent identifier unique to each ultimate parent/sector combination., *isin_direct_loantaker
(logical): Optional input: providing the isin identifier of the direct loan taker to improve the matching coverage., *lei_direct_loantaker
(logical): Optional input: providing the lei (legal entity identifier) of the direct loan taker to improve the matching coverage., *loan_size_credit_limit
(double): Total credit limit or exposure at default., *loan_size_credit_limit_currency
(character): Currency corresponding to credit limit., *loan_size_outstanding
(double): Amount drawn by borrower from total credit limit., *loan_size_outstanding_currency
(character): Currency corresponding to outstandings., *name_direct_loantaker
(character): Name of the company directly taking the loan., *name_ultimate_parent
(character): Name of the ultimate parent company to which the borrower belongs. Can be the same as borrower., *sector_classification_direct_loantaker
(double): Sector classification code of the direct loantaker., *sector_classification_system
(character): Name of the sector classification standard being used.
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
market_share_demo
,
overwrite_demo
,
region_isos_demo
,
scenario_demo_2020
,
sda_demo
Examples
head(loanbook_demo)
An example of a market_share_demo
-like dataset
Description
Dataset imitating the output of r2dii.analysis::target_market_share()
.
Usage
market_share_demo
Format
An object of class spec_tbl_df
(inherits from tbl_df
, tbl
, data.frame
) with 802 rows and 10 columns.
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
loanbook_demo
,
overwrite_demo
,
region_isos_demo
,
scenario_demo_2020
,
sda_demo
Examples
market_share_demo
Match a loanbook to asset-based company data (abcd) by the name_*
columns
Description
match_name()
scores the match between names in a loanbook dataset (columns
can be name_direct_loantaker
, name_intermediate_parent*
and
name_ultimate_parent
) with names in an asset-based company data (column
name_company
). The raw names are first internally transformed, and aliases
are assigned. The similarity between aliases in each of the loanbook and abcd
is scored using stringdist::stringsim()
.
Usage
match_name(
loanbook,
abcd,
by_sector = TRUE,
min_score = 0.8,
method = "jw",
p = 0.1,
overwrite = NULL,
join_id = NULL,
sector_classification = default_sector_classification(),
...
)
Arguments
loanbook , abcd |
data frames structured like r2dii.data::loanbook_demo and r2dii.data::abcd_demo. |
by_sector |
Should names only be compared if companies belong to the
same |
min_score |
A number between 0-1, to set the minimum |
method |
Method for distance calculation. One of |
p |
Prefix factor for Jaro-Winkler distance. The valid range for
|
overwrite |
A data frame used to overwrite the |
join_id |
A join specification passed to |
sector_classification |
A data frame containing sector classifications
in the same format as |
... |
Arguments passed on to |
Value
A data frame with the same groups (if any) and columns as loanbook
,
and the additional columns:
-
id_2dii
- an id used internally bymatch_name()
to distinguish companies -
level
- the level of granularity that the loan was matched at (e.gdirect_loantaker
orultimate_parent
) -
sector
- the sector of theloanbook
company -
sector_abcd
- the sector of theabcd
company -
name
- the name of theloanbook
company -
name_abcd
- the name of theabcd
company -
score
- the score of the match (manually set this to1
prior to callingprioritize()
to validate the match) -
source
- determines the source of the match. (equal toloanbook
unless the match is fromoverwrite
The returned rows depend on the argument min_value
and the result of the
column score
for each loan: * If any row has score
equal to 1,
match_name()
returns all rows where score
equals 1, dropping all other
rows. * If no row has score
equal to 1,match_name()
returns all rows
where score
is equal to or greater than min_score
. * If there is no
match the output is a 0-row tibble with the expected column names – for
type stability.
Assigning aliases
The transformation process used to compare names between loanbook and abcd datasets applies best practices commonly used in name matching algorithms:
Remove special characters.
Replace language specific characters.
Abbreviate certain names to reduce their importance in the matching.
Spell out numbers to increase their importance.
Handling grouped data
This function ignores but preserves existing groups.
See Also
Other matching functions:
crucial_lbk()
,
prioritize()
,
prioritize_level()
Examples
library(r2dii.data)
library(tibble)
# Small data for examples
loanbook <- head(loanbook_demo, 50)
abcd <- head(abcd_demo, 50)
match_name(loanbook, abcd)
match_name(loanbook, abcd, min_score = 0.9)
# match on LEI
loanbook <- tibble(
sector_classification_system = "NACE",
sector_classification_direct_loantaker = "D35.11",
id_ultimate_parent = "UP15",
name_ultimate_parent = "Won't fuzzy match",
id_direct_loantaker = "C294",
name_direct_loantaker = "Won't fuzzy match",
lei_direct_loantaker = "LEI123"
)
abcd <- tibble(
name_company = "alpine knits india pvt. limited",
sector = "power",
lei = "LEI123"
)
match_name(loanbook, abcd, join_id = c(lei_direct_loantaker = "lei"))
# Use your own `sector_classifications`
your_classifications <- tibble(
sector = "power",
borderline = FALSE,
code = "D35.11",
code_system = "XYZ"
)
loanbook <- tibble(
sector_classification_system = "XYZ",
sector_classification_direct_loantaker = "D35.11",
id_ultimate_parent = "UP15",
name_ultimate_parent = "Alpine Knits India Pvt. Limited",
id_direct_loantaker = "C294",
name_direct_loantaker = "Yuamen Xinneng Thermal Power Co Ltd"
)
abcd <- tibble(
name_company = "alpine knits india pvt. limited",
sector = "power"
)
match_name(loanbook, abcd, sector_classification = your_classifications)
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
nace_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1047 rows and 6 columns.
Definitions
-
borderline
(logical): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope., *code
(character): NACE version 2.1 code with top-level letter prepended., *description
(character): Original NACE version 2.1 description., *original_code
(character): Original NACE version 2.1 code., *sector
(character): Associated PACTA sector., *version
(character): Column identifying to which NACE version the code belongs.
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(nace_classification)
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
naics_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 2125 rows and 5 columns.
Definitions
-
borderline
(logical): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope.., *code
(character): Six-digit NAICS code., *description
(character): Original NAICS sector title., *sector
(character): Associated PACTA sector., *version
(character): Column identifying which year the classification was published in..
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(naics_classification)
A demonstration dataset used to overwrite specific entity names or sectors
Description
Fake dataset used to manually link loanbook entities to mismatched asset level entities.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
Usage
overwrite_demo
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 2 rows and 5 columns.
Definitions
-
id_2dii
(character): IDs of the entities to overwrite., *level
(character): Which level should be overwritten (e.g. direct_loantaker or ultimate_parent)., *name
(character): Overwrite name (if only overwriting sector, type NA)., *sector
(character): Overwrite sector (if only overwriting name, type NA)., *source
(character): What is the source of this information (leave as "manual" for now, may remove this flag later).
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
loanbook_demo
,
market_share_demo
,
region_isos_demo
,
scenario_demo_2020
,
sda_demo
Examples
head(overwrite_demo)
Conflicts between the {pacta.loanbook}
and other packages
Description
This function lists all the conflicts between packages in the
{pacta.loanbook}
and other packages that you have loaded.
Usage
pacta_loanbook_conflicts(only = NULL)
Arguments
only |
Set this to a character vector to restrict to conflicts only with these packages. |
Details
There are four conflicts that are deliberately ignored: intersect
,
union
, setequal
, and setdiff
from dplyr. These functions
make the base equivalents generic, so shouldn't negatively affect any
existing code.
Value
a pacta_loanbook_conflicts
classed list which will print a list of
conflicts to the console in interactive sessions, or NULL
if no conflicts
are found.
See Also
Other utility functions:
pacta_loanbook_deps()
,
pacta_loanbook_logo()
,
pacta_loanbook_packages()
,
pacta_loanbook_sitrep()
,
pacta_loanbook_update()
Examples
pacta_loanbook_conflicts()
List all {pacta.loanbook}
dependencies
Description
List all {pacta.loanbook}
dependencies
Usage
pacta_loanbook_deps(recursive = FALSE, repos = getOption("repos"))
Arguments
recursive |
If |
repos |
The repositories to use to check for updates.
Defaults to |
Value
a tibble
containing the local and CRAN versions of dependent
packages.
See Also
Other utility functions:
pacta_loanbook_conflicts()
,
pacta_loanbook_logo()
,
pacta_loanbook_packages()
,
pacta_loanbook_sitrep()
,
pacta_loanbook_update()
Examples
pacta_loanbook_deps(repos = "https://cran.r-project.org")
The {pacta.loanbook}
logo, using ASCII or Unicode characters
Description
Use cli::ansi_strip()
to get rid of the colors.
Usage
pacta_loanbook_logo(unicode = cli::is_utf8_output())
Arguments
unicode |
Whether to use Unicode symbols. Default is |
Value
a pacta_loanbook_logo
classed cli_ansi_string
which will print
the PACTA logo in the console in interactive sessions.
See Also
Other utility functions:
pacta_loanbook_conflicts()
,
pacta_loanbook_deps()
,
pacta_loanbook_packages()
,
pacta_loanbook_sitrep()
,
pacta_loanbook_update()
Examples
pacta_loanbook_logo()
List all packages in {pacta.loanbook}
Description
List all packages in {pacta.loanbook}
Usage
pacta_loanbook_packages(include_self = TRUE)
Arguments
include_self |
Include |
Value
a character vector containing the names of packages imported by
{pacta.loanbook}
.
See Also
Other utility functions:
pacta_loanbook_conflicts()
,
pacta_loanbook_deps()
,
pacta_loanbook_logo()
,
pacta_loanbook_sitrep()
,
pacta_loanbook_update()
Examples
pacta_loanbook_packages()
Get a situation report on {pacta.loanbook}
Description
This function gives a quick overview of the versions of R and RStudio as well
as the {pacta.loanbook}
package. It's primarily designed to help you get a
quick idea of what's going on when you're helping someone else debug a
problem.
Usage
pacta_loanbook_sitrep(repos = getOption("repos"))
Arguments
repos |
The repositories to use to check for updates.
Defaults to |
Value
returns NULL
invisibly. The function is called for its side effect
of printing a situation report of {pacta.loanbook}
and its core packages.
See Also
Other utility functions:
pacta_loanbook_conflicts()
,
pacta_loanbook_deps()
,
pacta_loanbook_logo()
,
pacta_loanbook_packages()
,
pacta_loanbook_update()
Examples
pacta_loanbook_sitrep(repos = "https://cran.r-project.org")
Update {pacta.loanbook}
packages
Description
This will check to see if all {pacta.loanbook}
packages (and optionally,
their dependencies) are up-to-date, and will install after an interactive
confirmation.
Usage
pacta_loanbook_update(recursive = FALSE, repos = getOption("repos"))
Arguments
recursive |
If |
repos |
The repositories to use to check for updates.
Defaults to |
Value
returns NULL
invisibly. The function is called for its side effect
of printing the status of locally installed, relevant packages.
See Also
Other utility functions:
pacta_loanbook_conflicts()
,
pacta_loanbook_deps()
,
pacta_loanbook_logo()
,
pacta_loanbook_packages()
,
pacta_loanbook_sitrep()
Examples
pacta_loanbook_update(repos = "https://cran.r-project.org")
Colour datasets
Description
All datasets have at least two columns:
-
label
: Text label of the colour. -
hex
: Hex code of the colour.
Usage
palette_colours
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 9 rows and 2 columns.
Details
In scenario_colours
, colours are ordered from red to green to be used in
trajectory charts.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
palette_colours
scenario_colours
sector_colours
technology_colours
Create an emission intensity plot
Description
Create an emission intensity plot
Usage
plot_emission_intensity(data)
Arguments
data |
A data frame like the output of |
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# plot with `qplot_emission_intensity()` parameters
data <- subset(sda_demo, sector == "cement" & region == "global")
data <- prep_emission_intensity(data, span_5yr = TRUE, convert_label = to_title)
plot_emission_intensity(data)
Create a techmix plot
Description
Create a techmix plot
Usage
plot_techmix(data)
Arguments
data |
A data frame like the output of |
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# plot with `qplot_techmix()` parameters
data <- subset(
market_share_demo,
scenario_source == "demo_2020" &
sector == "power" &
region == "global" &
metric %in% c("projected", "corporate_economy", "target_sds")
)
data <- prep_techmix(
data,
span_5yr = TRUE,
convert_label = recode_metric_techmix,
convert_tech_label = spell_out_technology
)
plot_techmix(data)
Create a trajectory plot
Description
Create a trajectory plot
Usage
plot_trajectory(data, center_y = FALSE, perc_y_scale = FALSE)
Arguments
data |
A data frame like the outputs of
|
center_y |
Logical. Use |
perc_y_scale |
Logical. |
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# plot with `qplot_trajectory()` parameters
data <- subset(
market_share_demo,
sector == "power" &
technology == "renewablescap" &
region == "global" &
scenario_source == "demo_2020"
)
data <- prep_trajectory(data)
plot_trajectory(
data,
center_y = TRUE,
perc_y_scale = TRUE
)
Prepare data for a emission intensity plot
Description
Prepare data for a emission intensity plot
Usage
prep_emission_intensity(data, convert_label = identity, span_5yr = FALSE)
Arguments
data |
A data frame. Requirements:
|
convert_label |
A symbol. The unquoted name of a function to apply to y-axis labels. For example:
|
span_5yr |
Logical. Use |
Value
A data-frame ready to be plotted using plot_emission_intensity()
.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(sda_demo, sector == "cement" & region == "global")
prep_emission_intensity(data)
Prepare data for plotting technology mix
Description
Prepare data for plotting technology mix
Usage
prep_techmix(
data,
convert_label = identity,
span_5yr = FALSE,
convert_tech_label = identity
)
Arguments
data |
A data frame. Requirements:
|
convert_label |
A symbol. The unquoted name of a function to apply to y-axis labels. For example:
|
span_5yr |
Logical. Use |
convert_tech_label |
A symbol. The unquoted name of a function to apply
to technology legend labels. For example, to convert labels to uppercase
use |
Value
A data-frame ready to be plotted using plot_techmix()
.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(
market_share_demo,
scenario_source == "demo_2020" &
sector == "power" &
region == "global" &
metric %in% c("projected", "corporate_economy", "target_sds")
)
prep_techmix(data)
Prepare data for a trajectory plot
Description
Prepare data for a trajectory plot
Usage
prep_trajectory(
data,
convert_label = identity,
span_5yr = FALSE,
value_col = "percentage_of_initial_production_by_scope"
)
Arguments
data |
A data frame. Requirements:
|
convert_label |
A symbol. The unquoted name of a function to apply to y-axis labels. For example:
|
span_5yr |
Logical. Use |
value_col |
Character. Name of the column to be used as a value to be plotted. |
Value
A data-frame ready to be plotted using plot_trajectory()
.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(
market_share_demo,
sector == "power" &
technology == "renewablescap" &
region == "global" &
scenario_source == "demo_2020"
)
prep_trajectory(data)
Pick rows where score
is 1 and level
per loan is of highest priority
Description
When multiple perfect matches are found per loan (e.g. a match at
direct_loantaker
level and ultimate_parent
level), we must prioritize the
desired match. By default, the highest priority
is the most granular match
(i.e. direct_loantaker
).
Usage
prioritize(data, priority = NULL)
Arguments
data |
A data frame like the validated output of |
priority |
One of:
|
Details
How to validate data
Write the output of match_name()
into a .csv file with:
# Writting to current working directory matched %>% readr::write_csv("matched.csv")
Compare, edit, and save the data manually:
Open matched.csv with any spreadsheet editor (Excel, Google Sheets, etc.).
Compare the columns
name
andname_abcd
manually to determine if the match is valid. Other information can be used in conjunction with just the names to ensure the two entities match (sector, internal information on the company structure, etc.)Edit the data:
If you are happy with the match, set the
score
value to1
.Otherwise set or leave the
score
value to anything other than1
.
Save the edited file as, say, valid_matches.csv.
Re-read the edited file (validated) with:
# Reading from current working directory valid_matches <- readr::read_csv("valid_matches.csv")
Value
A data frame with a single row per loan, where score
is 1 and
priority level is highest.
Handling grouped data
This function ignores but preserves existing groups.
See Also
Other matching functions:
crucial_lbk()
,
match_name()
,
prioritize_level()
Examples
library(dplyr)
# styler: off
matched <- tribble(
~sector, ~sector_abcd, ~score, ~id_loan, ~level,
"coal", "coal", 1, "aa", "ultimate_parent",
"coal", "coal", 1, "aa", "direct_loantaker",
"coal", "coal", 1, "bb", "intermediate_parent",
"coal", "coal", 1, "bb", "ultimate_parent",
)
# styler: on
prioritize_level(matched)
# Using default priority
prioritize(matched)
# Using the reverse of the default priority
prioritize(matched, priority = rev)
# Same
prioritize(matched, priority = ~ rev(.x))
# Using a custom priority
bad_idea <- c("intermediate_parent", "ultimate_parent", "direct_loantaker")
prioritize(matched, priority = bad_idea)
Arrange unique level
values in default order of priority
Description
Arrange unique level
values in default order of priority
Usage
prioritize_level(data)
Arguments
data |
A data frame, commonly the output of |
Value
A character vector of the default level priority per loan.
See Also
Other matching functions:
crucial_lbk()
,
match_name()
,
prioritize()
Examples
matched <- tibble::tibble(
level = c(
"intermediate_parent_1",
"direct_loantaker",
"direct_loantaker",
"direct_loantaker",
"ultimate_parent",
"intermediate_parent_2"
)
)
prioritize_level(matched)
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
psic_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1271 rows and 5 columns.
Definitions
-
borderline
(logical): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope.., *code
(character): Formatted PSIC classification code., *description
(character): Original PSIC classification sector name., *sector
(character): Associated PACTA sector., *version
(character): Column identifying which year the classification was published in..
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(psic_classification)
Create a quick emission intensity plot
Description
Compared to plot_emission_intensity()
this function:
is restricted to plotting future as 5 years from the start year,
outputs formatted labels, based on emission metric column,
outputs a title,
outputs formatted axis labels.
Usage
qplot_emission_intensity(data)
Arguments
data |
A data frame like the output of |
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(sda_demo, sector == "cement" & region == "global")
qplot_emission_intensity(data)
Create a quick techmix plot
Description
Compared to plot_techmix()
this function:
is restricted to plotting future as 5 years from the start year,
outputs pretty bar labels, based on metric column,
outputs pretty legend labels, based on technology column,
outputs a title.
Usage
qplot_techmix(data)
Arguments
data |
A data frame like the output of |
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(
market_share_demo,
sector == "power" &
region == "global" &
scenario_source == "demo_2020" &
metric %in% c("projected", "corporate_economy", "target_sds")
)
qplot_techmix(data)
Create a quick trajectory plot
Description
Compared to plot_trajectory()
this function:
is restricted to plotting only 5 years from the start year,
outputs pretty legend labels, based on the column holding metrics,
outputs a title,
outputs a subtitle,
outputs informative axis labels in sentence case.
Usage
qplot_trajectory(data)
Arguments
data |
A data frame like the outputs of
|
Value
An object of class "ggplot".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
# `data` must meet documented "Requirements"
data <- subset(
market_share_demo,
sector == "power" &
technology == "renewablescap" &
region == "global" &
scenario_source == "demo_2020"
)
qplot_trajectory(data)
Replicate labels produced with qplot_*()
functions
Description
-
to_title()
converts labels likeqplot_emission_intensity()
. -
recode_metric_trajectory()
converts labels likeqplot_trajectory()
. -
recode_metric_techmix()
converts labels likeqplot_techmix()
. -
spell_out_technology()
converts technology labels likeqplot_techmix()
.
Usage
recode_metric_techmix(x)
Arguments
x |
A character vector. |
Value
A character vector.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
to_title(c("a.string", "another_STRING"))
metric <- c("projected", "corporate_economy", "target_xyz", "else")
recode_metric_trajectory(metric)
recode_metric_techmix(metric)
spell_out_technology(c("gas", "ice", "coalcap", "hdv"))
Replicate labels produced with qplot_*()
functions
Description
-
to_title()
converts labels likeqplot_emission_intensity()
. -
recode_metric_trajectory()
converts labels likeqplot_trajectory()
. -
recode_metric_techmix()
converts labels likeqplot_techmix()
. -
spell_out_technology()
converts technology labels likeqplot_techmix()
.
Usage
recode_metric_trajectory(x)
Arguments
x |
A character vector. |
Value
A character vector.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
to_title(c("a.string", "another_STRING"))
metric <- c("projected", "corporate_economy", "target_xyz", "else")
recode_metric_trajectory(metric)
recode_metric_techmix(metric)
spell_out_technology(c("gas", "ice", "coalcap", "hdv"))
A dataset outlining various region definitions
Description
This dataset maps codes representing countries to regions.
For information about the ISO standard for country codes see https://www.iso.org/iso-3166-country-codes.html.
Usage
region_isos
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 9262 rows and 3 columns.
Definitions
-
isos
(character): Countries in region, defined by iso code., *region
(character): Benchmark region name., *source
(character): Source publication from which the regions are defined.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(region_isos)
A dataset outlining various region definitions
Description
This dataset maps codes representing countries to regions. It is similar to but smaller than region_isos.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
For information about the ISO standard for country codes see https://www.iso.org/iso-3166-country-codes.html.
Usage
region_isos_demo
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 358 rows and 3 columns.
Definitions
-
isos
(character): Countries in region, defined by iso code., *region
(character): Benchmark region name., *source
(character): Source publication from which the regions are defined.
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
loanbook_demo
,
market_share_demo
,
overwrite_demo
,
scenario_demo_2020
,
sda_demo
Examples
region_isos_demo
Custom PACTA colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA palette.
Usage
scale_colour_r2dii(colour_labels = NULL, ...)
Arguments
colour_labels |
A character vector. Specifies colour labels to use and their
order. Run |
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii()
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii()
Custom PACTA sector colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA sector palette.
Usage
scale_colour_r2dii_sector(sectors = NULL, ...)
Arguments
sectors |
A character vector. Specifies sector colours to use and their
order. Run |
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii_sector()
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii_sector()
Custom PACTA technology colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA technology palette.
Usage
scale_colour_r2dii_tech(sector, technologies = NULL, ...)
Arguments
sector |
A string. Sector name specifying a colour palette. Run
|
technologies |
A character vector. Specifies technologies to use as
colours and their order. Run
|
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii_tech("automotive")
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii_tech("automotive")
Custom PACTA colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA palette.
Usage
scale_fill_r2dii(colour_labels = NULL, ...)
Arguments
colour_labels |
A character vector. Specifies colour labels to use and their
order. Run |
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii()
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii()
Custom PACTA sector colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA sector palette.
Usage
scale_fill_r2dii_sector(sectors = NULL, ...)
Arguments
sectors |
A character vector. Specifies sector colours to use and their
order. Run |
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii_sector()
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii_sector()
Custom PACTA technology colour and fill scales
Description
A custom discrete colour and fill scales with colours from the PACTA technology palette.
Usage
scale_fill_r2dii_tech(sector, technologies = NULL, ...)
Arguments
sector |
A string. Sector name specifying a colour palette. Run
|
technologies |
A character vector. Specifies technologies to use as
colours and their order. Run
|
... |
Other parameters passed on to |
Value
An object of class "ScaleDiscrete".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
spell_out_technology()
,
theme_2dii()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mpg) +
geom_point(aes(displ, hwy, color = class)) +
scale_colour_r2dii_tech("automotive")
ggplot(mpg) +
geom_histogram(aes(cyl, fill = class), position = "dodge", bins = 5) +
scale_fill_r2dii_tech("automotive")
Colour datasets
Description
All datasets have at least two columns:
-
label
: Text label of the colour. -
hex
: Hex code of the colour.
Usage
scenario_colours
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 5 rows and 2 columns.
Details
In scenario_colours
, colours are ordered from red to green to be used in
trajectory charts.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
sector_classifications
,
sector_colours
,
sic_classification
,
technology_colours
Examples
palette_colours
scenario_colours
sector_colours
technology_colours
A prepared climate scenario dataset for demonstration
Description
Fake climate scenario dataset, prepared for the software PACTA (Paris Agreement Capital Transition Assessment). It imitates climate scenario data (e.g. from the International Energy Agency (IEA)) including the change through time in production across industrial sectors.
Demo datasets are synthetic because most financial data is strictly private; they help to demonstrate and test the implementation in R of 'PACTA' (https://www.transitionmonitor.com/).
Usage
scenario_demo_2020
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1512 rows and 8 columns.
Definitions
-
region
(character): The region to which the pathway is relevant., *scenario
(character): The name of the scenario., *scenario_source
(character): The source publication from which the scenario was taken., *sector
(character): The sector to which the scenario prescribes a pathway., *smsp
(double): Sector market share percentage of the pathway calculated in 2020., *technology
(character): The technology within the sector to which the scenario prescribes a pathway., *tmsr
(double): Technology market share ratio of the pathway calculated in 2020., *year
(integer): The year at which the pathway value is prescribed.
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
loanbook_demo
,
market_share_demo
,
overwrite_demo
,
region_isos_demo
,
sda_demo
Examples
head(scenario_demo_2020)
An example of an sda_demo
-like dataset
Description
Dataset imitating the output of r2dii.analysis::target_sda()
.
Usage
sda_demo
Format
An object of class spec_tbl_df
(inherits from tbl_df
, tbl
, data.frame
) with 110 rows and 6 columns.
Source
https://github.com/RMI-PACTA/r2dii.plot/issues/55.
See Also
Other demo data:
abcd_demo
,
co2_intensity_scenario_demo
,
loanbook_demo
,
market_share_demo
,
overwrite_demo
,
region_isos_demo
,
scenario_demo_2020
Examples
sda_demo
A view of available sector classification datasets
Description
This dataset lists all sector classification code standards used by 'PACTA' (https://www.transitionmonitor.com/).
Usage
sector_classifications
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 6559 rows and 4 columns.
Definitions
-
borderline
(character): Flag indicating if 2dii sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the 2dii sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of 2dii's scope.., *code
(character): Formatted code., *code_system
(character): Code system., *sector
(character): Associated 2dii sector.
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_colours
,
sic_classification
,
technology_colours
Examples
head(sector_classifications)
Colour datasets
Description
All datasets have at least two columns:
-
label
: Text label of the colour. -
hex
: Hex code of the colour.
Usage
sector_colours
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 8 rows and 2 columns.
Details
In scenario_colours
, colours are ordered from red to green to be used in
trajectory charts.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sic_classification
,
technology_colours
Examples
palette_colours
scenario_colours
sector_colours
technology_colours
Dataset to bridge (translate) common sector-classification codes
Description
This dataset serves as a translation key between common sector-classification systems and sectors relevant to the 'PACTA' tool (https://www.transitionmonitor.com/).
Usage
sic_classification
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1005 rows and 5 columns.
Definitions
-
borderline
(character): Flag indicating if PACTA sector and classification code are a borderline match. The value TRUE indicates that the match is uncertain between the PACTA sector and the classification. The value FALSE indicates that the match is certainly perfect or the classification is certainly out of PACTA's scope.., *code
(character): Original SIC code., *description
(character): Original SIC description., *sector
(character): Associated PACTA sector., *version
(character): Column identifying to which SIC version the code belongs.
Details
Classification datasets help to standardize sector classification codes from the wild to a relevant subset including 'power', 'oil and gas', 'coal', 'automotive', 'aviation', 'concrete', 'steel', and 'shipping'.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
technology_colours
Examples
head(sic_classification)
Replicate labels produced with qplot_*()
functions
Description
-
to_title()
converts labels likeqplot_emission_intensity()
. -
recode_metric_trajectory()
converts labels likeqplot_trajectory()
. -
recode_metric_techmix()
converts labels likeqplot_techmix()
. -
spell_out_technology()
converts technology labels likeqplot_techmix()
.
Usage
spell_out_technology(x)
Arguments
x |
A character vector. |
Value
A character vector.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
theme_2dii()
,
to_title()
Examples
to_title(c("a.string", "another_STRING"))
metric <- c("projected", "corporate_economy", "target_xyz", "else")
recode_metric_trajectory(metric)
recode_metric_techmix(metric)
spell_out_technology(c("gas", "ice", "coalcap", "hdv"))
Add targets for production, using the market share approach
Description
This function calculates the portfolio-level production targets, as calculated using the market share approach applied to each relevant climate production forecast.
Usage
target_market_share(
data,
abcd,
scenario,
region_isos = r2dii.data::region_isos,
use_credit_limit = FALSE,
by_company = FALSE,
weight_production = TRUE,
increasing_or_decreasing = r2dii.data::increasing_or_decreasing
)
Arguments
data |
A "data.frame" like the output of |
abcd |
An asset level data frame like r2dii.data::abcd_demo. |
scenario |
A scenario data frame like r2dii.data::scenario_demo_2020. |
region_isos |
A data frame like r2dii.data::region_isos (default). |
use_credit_limit |
Logical vector of length 1. |
by_company |
Logical vector of length 1. |
weight_production |
Logical vector of length 1. |
increasing_or_decreasing |
A data frame like r2dii.data::increasing_or_decreasing. |
Value
A tibble including the summarized columns metric
, production
,
technology_share
, percentage_of_initial_production_by_scope
and
scope
. If by_company = TRUE
, the output will also have the column
name_abcd
.
Handling grouped data
This function ignores existing groups and outputs ungrouped data.
See Also
Other analysis functions:
target_sda()
Examples
library(r2dii.data)
library(r2dii.match)
loanbook <- head(loanbook_demo, 100)
abcd <- head(abcd_demo, 100)
matched <- loanbook %>%
match_name(abcd) %>%
prioritize()
# Calculate targets at portfolio level
matched %>%
target_market_share(
abcd = abcd,
scenario = scenario_demo_2020,
region_isos = region_isos_demo
)
# Calculate targets at company level
matched %>%
target_market_share(
abcd = abcd,
scenario = scenario_demo_2020,
region_isos = region_isos_demo,
by_company = TRUE
)
matched %>%
target_market_share(
abcd = abcd,
scenario = scenario_demo_2020,
region_isos = region_isos_demo,
# Calculate unweighted targets
weight_production = FALSE
)
Add targets for CO2 emissions per unit production at the portfolio level, using the SDA approach
Description
This function calculates targets of CO2 emissions per unit production at the portfolio-level, otherwise referred to as "emissions factors". It uses the sectoral-decarbonization approach (SDA) to calculate these targets.
Usage
target_sda(
data,
abcd,
co2_intensity_scenario,
use_credit_limit = FALSE,
by_company = FALSE,
region_isos = r2dii.data::region_isos
)
Arguments
data |
A dataframe like the output of
|
abcd |
An asset-level data frame like r2dii.data::abcd_demo. |
co2_intensity_scenario |
A scenario data frame like r2dii.data::co2_intensity_scenario_demo. |
use_credit_limit |
Logical vector of length 1. |
by_company |
Logical vector of length 1. |
region_isos |
A data frame like r2dii.data::region_isos (default). |
Value
A tibble including the summarized columns emission_factor_metric
and
emission_factor_value
. If by_company = TRUE
, the output will also have
the column name_abcd
.
Handling grouped data
This function ignores existing groups and outputs ungrouped data.
See Also
Other analysis functions:
target_market_share()
Examples
library(r2dii.match)
library(r2dii.data)
loanbook <- head(loanbook_demo, 150)
abcd <- head(abcd_demo, 100)
matched <- loanbook %>%
match_name(abcd) %>%
prioritize()
# Calculate targets at portfolio level
matched %>%
target_sda(
abcd = abcd,
co2_intensity_scenario = co2_intensity_scenario_demo,
region_isos = region_isos_demo
)
# Calculate targets at company level
matched %>%
target_sda(
abcd = abcd,
co2_intensity_scenario = co2_intensity_scenario_demo,
region_isos = region_isos_demo,
by_company = TRUE
)
Colour datasets
Description
All datasets have at least two columns:
-
label
: Text label of the colour. -
hex
: Hex code of the colour.
Usage
technology_colours
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 18 rows and 3 columns.
Details
In scenario_colours
, colours are ordered from red to green to be used in
trajectory charts.
See Also
Other datasets:
gics_classification
,
increasing_or_decreasing
,
isic_classification
,
iso_codes
,
nace_classification
,
naics_classification
,
palette_colours
,
psic_classification
,
region_isos
,
scenario_colours
,
sector_classifications
,
sector_colours
,
sic_classification
Examples
palette_colours
scenario_colours
sector_colours
technology_colours
Complete theme
Description
A ggplot theme which can be applied to all graphs to appear according to the PACTA plotting aesthetics.
Usage
theme_2dii(
base_size = 12,
base_family = "Helvetica",
base_line_size = base_size/22,
base_rect_size = base_size/22
)
Arguments
base_size |
base font size, given in pts. |
base_family |
base font family |
base_line_size |
base size for line elements |
base_rect_size |
base size for rect elements |
Value
An object of class "theme", "gg".
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
to_title()
Examples
library(ggplot2, warn.conflicts = FALSE)
ggplot(mtcars) +
geom_histogram(aes(mpg), bins = 10) +
theme_2dii()
Replicate labels produced with qplot_*()
functions
Description
-
to_title()
converts labels likeqplot_emission_intensity()
. -
recode_metric_trajectory()
converts labels likeqplot_trajectory()
. -
recode_metric_techmix()
converts labels likeqplot_techmix()
. -
spell_out_technology()
converts technology labels likeqplot_techmix()
.
Usage
to_title(x)
Arguments
x |
A character vector. |
Value
A character vector.
See Also
Other plotting functions:
plot_emission_intensity()
,
plot_techmix()
,
plot_trajectory()
,
prep_emission_intensity()
,
prep_techmix()
,
prep_trajectory()
,
qplot_emission_intensity()
,
qplot_techmix()
,
qplot_trajectory()
,
recode_metric_techmix()
,
recode_metric_trajectory()
,
scale_colour_r2dii()
,
scale_colour_r2dii_sector()
,
scale_colour_r2dii_tech()
,
scale_fill_r2dii()
,
scale_fill_r2dii_sector()
,
scale_fill_r2dii_tech()
,
spell_out_technology()
,
theme_2dii()
Examples
to_title(c("a.string", "another_STRING"))
metric <- c("projected", "corporate_economy", "target_xyz", "else")
recode_metric_trajectory(metric)
recode_metric_techmix(metric)
spell_out_technology(c("gas", "ice", "coalcap", "hdv"))