moco-water/workflow/scripts/standardize_ucmr_234.R

31 lines
806 B
R

library(tidyverse)
snakemake@input[[1]] %>%
readr::read_tsv(
col_types = cols(
PWSID = "c",
PWSName = "c",
FacilityID = "c",
FacilityName = "c",
SamplePointID = "c",
SamplePointName = "c",
SamplePointType = "c",
CollectionDate = "c",
Contaminant = "c",
AnalyticalResultsSign = "c",
AnalyticalResultValue = "d",
.default = "-"
)) %>%
rename(
sample_point_ID = SamplePointID,
sample_point_name = SamplePointName,
sample_point_type = SamplePointType,
facility_ID = FacilityID,
facility_Name = FacilityName,
date = CollectionDate,
species = Contaminant,
unit = AnalyticalResultsSign,
value = AnalyticalResultValue) %>%
mutate(date = as.Date(date, format = "%m/%d/%Y")) %>%
readr::write_tsv(snakemake@output[[1]])