Skip to content

Commit

Permalink
standardize how matched and prioritized loanbooks are read-in
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ Yetman - RMI authored and CJ Yetman - RMI committed Aug 20, 2024
1 parent c3ca19d commit 7105a5d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
20 changes: 7 additions & 13 deletions R/run_aggregate_alignment_metric.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,14 @@ run_aggregate_alignment_metric <- function(config) {
)

# read matched and prioritized loan book----
list_matched_prio <- list.files(dir_matched)[grepl("matched_prio_", list.files(dir_matched))]
list_matched_prioritized <- list.files(path = dir_matched, pattern = "^matched_prio_.*csv$")
stop_if_no_files_found(list_matched_prioritized, dir_matched, "dir_matched", "matched prioritized loan book CSVs")

matched_prioritized <- NULL

# combine all matched loan books into one object to loop over
for (i in list_matched_prio) {
matched_prioritized_i <- readr::read_csv(
file.path(dir_matched, i),
col_types = col_types_matched_prioritized
)

matched_prioritized <- matched_prioritized %>%
dplyr::bind_rows(matched_prioritized_i)
}
matched_prioritized <- readr::read_csv(
file = file.path(dir_matched, list_matched_prioritized),
col_types = col_types_matched_prioritized,
col_select = dplyr::all_of(col_select_matched_prioritized)
)

# aggregate P4B alignment----

Expand Down
1 change: 0 additions & 1 deletion R/run_calculate_loanbook_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ run_calculate_loanbook_coverage <- function(config) {
list_matched_prioritized <- list.files(path = dir_matched, pattern = "^matched_prio_.*csv$")
stop_if_no_files_found(list_matched_prioritized, dir_matched, "dir_matched", "matched prioritized loan book CSVs")


matched_prioritized <- readr::read_csv(
file = file.path(dir_matched, list_matched_prioritized),
col_types = col_types_matched_prioritized,
Expand Down
2 changes: 1 addition & 1 deletion R/run_calculate_match_success_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ run_calculate_match_success_rate <- function(config) {
)

## load matched prioritized loan books----
list_matched_prioritized <- list.files(dir_matched)[grepl("^matched_prio_.*csv$", list.files(dir_matched))]
list_matched_prioritized <- list.files(path = dir_matched, pattern = "^matched_prio_.*csv$")
stop_if_no_files_found(list_matched_prioritized, dir_matched, "dir_matched", "matched prioritized loan book CSVs")

matched_prioritized <- readr::read_csv(
Expand Down
21 changes: 7 additions & 14 deletions R/run_pacta.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,14 @@ run_pacta <- function(config) {
)

# read matched and prioritized loan book----
list_matched_prio <- list.files(input_path_matched)[grepl("matched_prio_", list.files(input_path_matched))]
list_matched_prioritized <- list.files(path = dir_matched, pattern = "^matched_prio_.*csv$")
stop_if_no_files_found(list_matched_prioritized, dir_matched, "dir_matched", "matched prioritized loan book CSVs")

matched_prioritized <- NULL

# combine all matched loan books into one object to loop over
for (i in list_matched_prio) {
matched_prioritized_i <- readr::read_csv(
file.path(input_path_matched, i),
col_types = col_types_matched_prioritized,
col_select = dplyr::all_of(col_select_matched_prioritized)
)

matched_prioritized <- matched_prioritized %>%
dplyr::bind_rows(matched_prioritized_i)
}
matched_prioritized <- readr::read_csv(
file = file.path(dir_matched, list_matched_prioritized),
col_types = col_types_matched_prioritized,
col_select = dplyr::all_of(col_select_matched_prioritized)
)

# meta loan book----
# aggregate all individual loan books into one meta loan book and add that to
Expand Down

0 comments on commit 7105a5d

Please sign in to comment.