Skip to content

V2.1 #4

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

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
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
13 changes: 12 additions & 1 deletion processing/process.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ parser = OptionParser(

make_option(
opt_str = c("-o", "--output"),
help = "Output file, in CSV format.",
help = "Output file, in parquet format.",
type = "character",
default = ""),

Expand Down Expand Up @@ -160,14 +160,25 @@ wtisen_data = read_csv(
"MUNICIPALITY",
"COUNTY"),
.fns = \(x) str_replace(x, "_", " ")),

across(
.cols = starts_with("DATE_"),
.fns = \(x) {x |>
as_datetime(format = c("%m/%d/%Y %I:%M:%S %p", "%Y-%m-%d %H:%M:%S")) |>
force_tz(tz = "America/Toronto")}),

# Convert erroneous collection dates to NAs
DATE_COLLECTED = case_when(
# Collected >6 months before receipt
DATE_COLLECTED < (DATE_RECEIVED - months(6)) ~ NA_POSIXct_,
# Collected after lab receipt
DATE_COLLECTED > DATE_RECEIVED ~ NA_POSIXct_,
.default = DATE_COLLECTED),

across(
.cols = where(is.character),
.fns = \(x) str_trim(x)),

POSTAL = postalcode_cleaner(POSTAL),
ENTRY = as.integer(ENTRY),
REQ_LEGIBLE = str_detect(REQ_LEGIBLE, "^y|Y$"))
Expand Down