|
- process_report_list <- function(report_list_raw, report_amended_score) {
- # select the correct report_id to use for each report group
-
- report_keep <-
- report_amended_score |>
- group_by(sboe_id, year, doc_name) |>
- slice_max(amended_score) |>
- # follow up to be certain there's only one report per group
- slice_max(report_id)
-
- report_keep_count <- report_keep |> count()
- if (any(report_keep_count$n > 1)) {
- stop("Have not successfully selected a single report per committee and report group.")
- }
-
- report_keep <- report_keep |> ungroup() |> select(report_id, matches("received|date"))
-
- report_list_raw |>
- select(-matches("received|date")) |>
- right_join(report_keep, by = "report_id") |>
- select(-committee_name, -doc_type, -tar_group, image_id = img_link) |>
- mutate(
- across(doc_name, as_report_factor),
- image_id = sub(".+?(\\d+)$", "\\1", image_id)
- )
- }
|