knitr::opts_chunk$set( cache = TRUE, collapse = TRUE, comment = "", echo = FALSE, fig.path = "man/figures/README-", out.width = "100%" ) # The code that uses fs is hidden to keep instructions short library(fs) library(pactaCore)
The goal of pactaCore is run the core steps of the PACTA methodology with a single command, in a reproducible way.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("2DegreesInvesting/pactaCore")
A good setup for a pacta project looks like this:
pacta <- path_home("pacta_tmp") example_inputs <- dir_ls( system.file("extdata", package = "pactaCore"), regexp = "Input" ) pactaCore:::create_pacta(pacta, input_paths = example) dir_tree(pacta, all = TRUE)
#> path/to/private/pacta-data/ #> ├── ... #> ...
env <- path(pacta, ".env") writeLines(readLines(env))
The input/ directory must contain portfolio files like TestPortfolio_Input.csv, and parameters files like TestPortfolio_Input_PortfolioParameters.yml.
The output/ directory typically starts empty.
The pacta-data/ directory is private. With permission get if from GitHub with:
# From the terminal
git clone git@github.com:2DegreesInvesting/pacta-data.git
Use the pactaCore package with library()
and run_pacta()
with your
environment file.
library(pactaCore) run_pacta(env = "~/pacta_tmp/.env")
The output/ directory is now populated with results:
dir_tree(pacta)
For each corresponding <pair-name>
, the portfolio and parameter files must be
named <pair-name>_Input.csv
and <pair-name>_Input_PortfolioParameters.yml
,
respectively. For example:
This pair is valid: a_Input.csv
, a_Input_PortfolioParameters.yml
.
This pair is invalid: a_Input.csv
, b_Input_PortfolioParameters.yml
.
In the parameter files, whatever values you give to portfolio_name_in
and
investor_name_in
will populate the columns portfolio_name
and
investor_name
of some output files. For example:
writeLines(readLines(example_inputs[[2]]))
paths <- fs::dir_ls(pactaCore:::results_path(pacta)) datasets <- lapply(paths, readRDS)
lapply(datasets, function(x) head(x[c("portfolio_name", "investor_name")]))
dir_delete(pacta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.