Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use prepared abcd in matching #153

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions R/run_match_prioritize.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ run_match_prioritize <- function(config) {
config <- load_config(config)

dir_matched <- get_matched_dir(config)
path_abcd <- get_abcd_path(config)
sheet_abcd <- get_abcd_sheet(config)
abcd_dir <- get_abcd_dir(config)

match_prio_priority <- get_match_priority(config)

apply_sector_split <- get_apply_sector_split(config)
sector_split_type_select <- get_sector_split_type(config)

# validate config values----
stop_if_not_length(abcd_dir, 1L)
stop_if_not_inherits(abcd_dir, "character")
stop_if_dir_not_found(abcd_dir, desc = "ABCD data")

jacobvjk marked this conversation as resolved.
Show resolved Hide resolved
stop_if_not_length(dir_matched, 1L)
stop_if_not_inherits(dir_matched, "character")
stop_if_dir_not_found(dir_matched, desc = "Matched loanbook")
Expand Down Expand Up @@ -62,9 +65,11 @@ run_match_prioritize <- function(config) {
col_select = dplyr::all_of(col_select_companies_sector_split)
)

# TODO: better use prepared abcd?
abcd <- read_abcd_raw(path_abcd, sheet_abcd)
stop_if_not_expected_columns(abcd, cols_abcd, desc = "ABCD")
abcd <- readr::read_csv(
file.path(abcd_dir, "abcd_final.csv"),
col_select = dplyr::all_of(cols_abcd),
col_types = col_types_abcd_final
)
}

# prioritize and save files----
Expand Down
16 changes: 9 additions & 7 deletions R/run_matching.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ run_matching <- function(config) {
config <- load_config(config)

dir_raw <- get_raw_dir(config)
path_abcd <- get_abcd_path(config)
sheet_abcd <- get_abcd_sheet(config)
abcd_dir <- get_abcd_dir(config)
dir_matched <- get_matched_dir(config)

matching_by_sector <- get_match_by_sector(config)
Expand All @@ -23,9 +22,9 @@ run_matching <- function(config) {
stop_if_not_inherits(dir_raw, "character")
stop_if_dir_not_found(dir_raw, desc = "Raw loanbook")

stop_if_not_length(path_abcd, 1L)
stop_if_not_inherits(path_abcd, "character")
stop_if_file_not_found(path_abcd, desc = "ABCD data")
stop_if_not_length(abcd_dir, 1L)
stop_if_not_inherits(abcd_dir, "character")
stop_if_dir_not_found(abcd_dir, desc = "ABCD data")
jacobvjk marked this conversation as resolved.
Show resolved Hide resolved

stop_if_not_length(dir_matched, 1L)
stop_if_not_inherits(dir_matched, "character")
Expand Down Expand Up @@ -64,8 +63,11 @@ run_matching <- function(config) {
# load data----

## load abcd----
abcd <- read_abcd_raw(path_abcd, sheet_abcd)
stop_if_not_expected_columns(abcd, cols_abcd, desc = "ABCD")
abcd <- readr::read_csv(
file.path(abcd_dir, "abcd_final.csv"),
col_select = dplyr::all_of(cols_abcd),
col_types = col_types_abcd_final
)

## optionally load manual classification system----
if (matching_use_manual_sector_classification) {
Expand Down
Loading