diff --git a/0_global_functions.R b/0_global_functions.R index 08b9b28c..418e238b 100644 --- a/0_global_functions.R +++ b/0_global_functions.R @@ -276,7 +276,7 @@ copy_files <- function(project_name) { input_file <- paste0(raw_input_path, "/", project_name, "_Input.csv") parameter_file <- paste0(par_file_path, "/ReportParameters.yml") - yml_file <- paste0(par_file_path, "/AnalysisParameters.yml") + yml_file <- paste0(par_file_path, "/ProjectParameters.yml") if (!file.exists(input_file)) { file.copy(paste0(folder_location, "/ProjectName_Input.csv"), input_file, overwrite = F) @@ -287,7 +287,7 @@ copy_files <- function(project_name) { } if (!file.exists(yml_file)) { - file.copy(paste0(folder_location, "/AnalysisParameters.yml"), yml_file, overwrite = F) + file.copy(paste0(folder_location, "/ProjectParameters.yml"), yml_file, overwrite = F) } } diff --git a/0_portfolio_input_check_functions.R b/0_portfolio_input_check_functions.R index 0d916916..03ce65a1 100644 --- a/0_portfolio_input_check_functions.R +++ b/0_portfolio_input_check_functions.R @@ -5,9 +5,9 @@ read_raw_portfolio_file <- function(project_name) { portfolio <- NA input_path <- paste0(project_location, "/20_Raw_Inputs/") - # pattern matches e.g.: "whatever_Input.csv" - csv_to_read <- list.files(path = input_path, pattern = "_Input[.]csv$") - txt_to_read <- list.files(path = input_path, pattern = "_Input[.]txt$") + + csv_to_read <- list.files(path = input_path, pattern = "_Input.csv") + txt_to_read <- list.files(path = input_path, pattern = "_Input.txt") if (length(csv_to_read) == 1) { @@ -418,7 +418,7 @@ check_fin_mapped_sectors <- function(fin_data) { )) actual_sectors <- unique(fin_data$security_mapped_sector) - if (any(!actual_sectors %in% c(sector_list, other_sector_list, "Other"))) { + if (any(!actual_sectors %in% c(sector_list, pacta_sectors_not_analysed, "Other"))) { stop("Additional Sectors in fin_data") } diff --git a/2_project_input_analysis.R b/2_project_input_analysis.R index 7e342aeb..8dafdff4 100644 --- a/2_project_input_analysis.R +++ b/2_project_input_analysis.R @@ -1,23 +1,4 @@ -## Project start -# File List Check for External Data Requirements: -# security_financial_data.rda -# consolidated_financial_data.rda -# debt_financial_data.rda -# bonds_ald_scenario.rda -# equity_ald_scenario.rda -# masterdata_ownership_datastore.rda -# masterdata_debt_datastore.rda - -# To do: write test to see that these files exist - -# optional: -# fund_data_2019Q4.rda (or relevant time stamp) -# revenue_data_member_ticker.rda (if not available, set has_revenue = FALSE in parameter file) - -# Obtains data, processes the portfolio and saves the files - -# todo: move this to parameter files -other_sector_list <- c("Steel", "Cement", "Shipping", "Aviation") +# This script obtains data, processes the portfolio and saves the files #################### #### DATA FILES #### diff --git a/3_run_analysis.R b/3_run_analysis.R index 68da092a..a4825bcd 100644 --- a/3_run_analysis.R +++ b/3_run_analysis.R @@ -1,7 +1,7 @@ # TODO: # Clean up sectors options -# port_col_types <- set_col_types(grouping_variables, "ddddccccddcl") +port_col_types <- set_col_types(grouping_variables, "ddddccccddclc") ################## ##### EQUITY ##### ################## @@ -12,9 +12,9 @@ if (file.exists(equity_input_file)) { port_raw_all_eq <- read_rds(equity_input_file) %>% mutate(id = as.character(id)) - # if (length(colnames(port_raw_all_eq)) != nchar(port_col_types)) { - # stop("Check port_col_types: difference in length") - # } + if (length(colnames(port_raw_all_eq)) != nchar(port_col_types)) { + stop("Check port_col_types: difference in length") + } ald_scen_eq <- get_ald_scen("Equity") @@ -100,9 +100,9 @@ if (file.exists(bonds_inputs_file)) { port_raw_all_cb <- read_rds(bonds_inputs_file) %>% mutate(id = as.character(id)) - # if (length(colnames(port_raw_all_cb)) != nchar(port_col_types)) { - # stop("Check port_col_types: difference in length") - # } + if (length(colnames(port_raw_all_cb)) != nchar(port_col_types)) { + stop("Check port_col_types: difference in length") + } ald_scen_cb <- get_ald_scen("Bonds")