Преглед изворни кода

task: table of committees

main
Garrick Aden-Buie пре 3 година
родитељ
комит
1f8f26ce30
No known key found for this signature in database
5 измењених фајлова са 22 додато и 21 уклоњено
  1. +11
    -0
      process/R/prepare_committees.R
  2. +1
    -1
      process/R/process_report_dates.R
  3. +0
    -14
      process/R/write_committee_parquet.R
  4. +3
    -1
      process/_targets.R
  5. +7
    -5
      process/_targets/meta/meta

+ 11
- 0
process/R/prepare_committees.R Прегледај датотеку

prepare_committees <- function(cover_raw, report_list = tar_read(report_list)) {
latest_report_by_committee <- report_list |> slice_max(end_date, by = "sboe_id")

cover_raw |>
semi_join(latest_report_by_committee, by = "report_id") |>
select(sboe_id:committee_type, fund_type, fund_name)
}

write_committee_parquet <- function(committees, out_path = "../data/committees.parquet") {
arrow::write_parquet(committees, out_path)
}

+ 1
- 1
process/R/process_report_dates.R Прегледај датотеку

select( select(
report_id, sboe_id, year, doc_name, amended, report_id, sboe_id, year, doc_name, amended,
contains("received_"), contains("received_"),
matches("sboe_(start|end)_date")
matches("(sboe_)?(start|end)_date")
) |> ) |>
left_join(cover_dates, by = "report_id") |> left_join(cover_dates, by = "report_id") |>
mutate(across(matches("received|date"), na_if_obviously_wrong_date)) |> mutate(across(matches("received|date"), na_if_obviously_wrong_date)) |>

+ 0
- 14
process/R/write_committee_parquet.R Прегледај датотеку

write_committee_parquet <- function(report_list = tar_read(report_list)) {
cover_path <- here::here("../data/cover")
cover <- arrow::open_dataset(cover_path, partitioning = "sboe_id")

latest_report_by_committee <- report_list |> slice_max(end_date, by = "sboe_id")

committees <-
cover |>
semi_join(latest_report_by_committee, by = "report_id") |>
collect() |>
select(sboe_id:committee_type, fund_type, fund_name)

arrow::write_parquet(committees, here::here("data/committees/part-0.parquet"))
}

+ 3
- 1
process/_targets.R Прегледај датотеку

tar_target( tar_target(
report_list, report_list,
process_report_list(report_list_raw, report_amended_score) process_report_list(report_list_raw, report_amended_score)
)
),

tar_target(committees, prepare_committees(cover_raw, report_list))
) )

+ 7
- 5
process/_targets/meta/meta
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


Loading…
Откажи
Сачувај