Skip to content

Commit

Permalink
Merge pull request #53 from RMI-PACTA/feat/19-export-prep-functions
Browse files Browse the repository at this point in the history
Feat/19 export prep functions
  • Loading branch information
AlexAxthelm authored Jan 2, 2025
2 parents 6b09542 + 3583afb commit df295d0
Show file tree
Hide file tree
Showing 14 changed files with 367 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: workflow.pacta.dashboard
Title: Run PACTA dashboard JSON generation
Version: 0.0.0.9008
Version: 0.0.0.9009
Authors@R:
c(person(given = "Alex",
family = "Axthelm",
Expand Down
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(prep_company_bubble)
export(prep_exposure_pie)
export(prep_exposure_stats)
export(prep_key_bars_company)
export(prep_key_bars_portfolio)
export(prep_techmix_sector)
export(prepare_schema_files)
export(run_dashboard_workflow)
importFrom(dplyr,across)
Expand Down
20 changes: 17 additions & 3 deletions R/prep_company_bubble.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# prep_company_bubble ----------------------------------------------------------
# based on pacta.portfolio.report:::prep_company_bubble, but does not filter to
# allocation == "portfolio_weight" nor by scenario and scenario source
#' Prepare data for company bubble plot
#'
#' Prepare JSON data for the company bubble plot.
#' Note: this is based on pacta.portfolio.report:::prep_company_bubble, but
#' does not filter to allocation == "portfolio_weight" nor by scenario and
#' scenario source.
#'
#' @param equity_results_company (data.frame) Company-level results from
#' `workflow.pacta` for listed equity
#' @param bonds_results_company (data.frame) Company-level results from
#' `workflow.pacta` for corporate bonds
#' @param portfolio_name (character scalar) Portfolio name
#' @param start_year (integer scalar) Start year for analysis
#' @param green_techs (character vector) List of green technologies
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_company_bubble <-
function(equity_results_company,
bonds_results_company,
Expand Down
14 changes: 14 additions & 0 deletions R/prep_exposure_pie.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#' Prepare data for exposure pie chart
#'
#' Prepare JSON data for the exposure pie chart.
#'
#' @param data (data.frame) Audit file contents
#' @param asset_type (character scalar) Asset type (`Equity` or `Bonds`)
#' @param investor_name (character scalar) Investor name
#' @param portfolio_name (character scalar) Portfolio name
#' @param pacta_sectors (character vector) PACTA sectors
#' @param currency_exchange_value (numeric scalar) Currency exchange value to
#' convert to USD
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_exposure_pie <-
function(data,
asset_type,
Expand Down
13 changes: 13 additions & 0 deletions R/prep_exposure_stats.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#' Prepare exposure statistics for inclusion in the dashboard
#'
#' Prepare JSON data for the exposure statistics.
#'
#' @param audit_file (data.frame) Audit file contents
#' @param investor_name (character scalar) Investor name
#' @param portfolio_name (character scalar) Portfolio name
#' @param pacta_sectors (character vector) PACTA sectors
#' @param currency_exchange_value (numeric scalar) Currency exchange value to
#' convert to USD
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_exposure_stats <- function(audit_file, investor_name, portfolio_name, pacta_sectors, currency_exchange_value) {
pacta_asset_classes <- c("Bonds", "Equity")

Expand Down
23 changes: 19 additions & 4 deletions R/prep_key_bars_company.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# prep_key_bars_company --------------------------------------------------------
# based on pacta.portfolio.report:::prep_key_bars_company, but does not filter
# to allocation == "portfolio_weight" nor by scenario and scenario source

#' Prepare data for company-level technology exposoure plot
#'
#' Prepare JSON data for the company-level technology exposoure plot.
#' Note: This is based on pacta.portfolio.report:::prep_key_bars_company, but
#' does not filter to allocation == "portfolio_weight" nor by scenario and
#' scenario source.
#'
#' @param equity_results_company (data.frame) Company-level results from
#' `workflow.pacta` for listed equity
#' @param bonds_results_company (data.frame) Company-level results from
#' `workflow.pacta` for corporate bonds
#' @param portfolio_name (character scalar) Portfolio name
#' @param start_year (integer scalar) Start year for analysis
#' @param pacta_sectors_not_analysed (character vector) PACTA sectors not to be
#' analysed
#' @param all_tech_levels (character vector) List of all technology levels
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_key_bars_company <-
function(equity_results_company,
bonds_results_company,
Expand Down
19 changes: 19 additions & 0 deletions R/prep_key_bars_portfolio.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
# based on pacta.portfolio.report:::prep_key_bars_portfolio, but does not filter
# to allocation == "portfolio_weight" nor by scenario and scenario source

#' Prepare data for portfolio-level technology exposoure plot
#'
#' Prepare JSON data for the portfolio-level technology exposoure plot.
#' Note: This is based on pacta.portfolio.report:::prep_key_bars_portfolio, but
#' does not filter to allocation == "portfolio_weight" nor by scenario and
#' scenario source.
#'
#' @param equity_results_portfolio (data.frame) Portfolio-level results from
#' `workflow.pacta` for listed equity
#' @param bonds_results_portfolio (data.frame) Portfolio-level results from
#' `workflow.pacta` for corporate bonds
#' @param portfolio_name (character scalar) Portfolio name
#' @param start_year (integer scalar) Start year for analysis
#' @param pacta_sectors_not_analysed (character vector) PACTA sectors not to be
#' analysed
#' @param all_tech_levels (character vector) List of all technology levels
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_key_bars_portfolio <-
function(equity_results_portfolio,
bonds_results_portfolio,
Expand Down
27 changes: 27 additions & 0 deletions R/prep_techmix_sector.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
#' Prepare techmix data for plot
#'
#' Prepare JSON data for the technology mix plot.
#'
#' @param equity_results_portfolio (data.frame) Portfolio-level results from
#' `workflow.pacta` for listed equity
#' @param bonds_results_portfolio (data.frame) Portfolio-level results from
#' `workflow.pacta` for corporate bonds
#' @param indices_equity_results_portfolio (data.frame) Benchmark results from
#' `workflow.pacta` for listed equity
#' @param indices_bonds_results_portfolio (data.frame) Benchmark results from
#' `workflow.pacta` for corporate bonds
#' @param peers_equity_results_portfolio (data.frame) Peer group results from
#' `workflow.pacta` for listed equity
#' @param peers_bonds_results_portfolio (data.frame) Peer group results from
#' `workflow.pacta` for corporate bonds
#' @param investor_name (character scalar) Investor name
#' @param portfolio_name (character scalar) Portfolio name
#' @param start_year (integer scalar) Start year for analysis
#' @param year_span (integer scalar) Number of years to analyze (from
#' `_start_year`)
#' @param peer_group (character scalar) Peer group name
#' @param green_techs (character vector) List of green technologies
#' @param all_tech_levels (character vector) List of all technology levels
#' @return (data.frame) suitible for serialization to JSON (using
#' `jsonlite::toJSON`/`jsonlite::write_json`)
#' @export
prep_techmix_sector <-
function(equity_results_portfolio,
bonds_results_portfolio,
Expand Down
37 changes: 37 additions & 0 deletions man/prep_company_bubble.Rd

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

36 changes: 36 additions & 0 deletions man/prep_exposure_pie.Rd

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

33 changes: 33 additions & 0 deletions man/prep_exposure_stats.Rd

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

41 changes: 41 additions & 0 deletions man/prep_key_bars_company.Rd

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

41 changes: 41 additions & 0 deletions man/prep_key_bars_portfolio.Rd

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

Loading

0 comments on commit df295d0

Please sign in to comment.