32 lines
800 B
R
32 lines
800 B
R
library(tidyverse)
|
|
|
|
read_tsv <- function(path) {
|
|
readr::read_tsv(
|
|
path,
|
|
col_types = cols(
|
|
PWSID = "c",
|
|
PWSName = "c",
|
|
"Facility ID" = "c",
|
|
"Sample point ID" = "c",
|
|
"Sample point type" = "c",
|
|
"Sample collection date" = "c",
|
|
Contaminant = "c",
|
|
"Unit measure" = "c",
|
|
Result = "d",
|
|
.default = "-"
|
|
))
|
|
}
|
|
|
|
df <- snakemake@input %>%
|
|
map_dfr(read_tsv) %>%
|
|
rename(sample_point_ID = "Sample point ID",
|
|
sample_point_type = "Sample point type",
|
|
facility_ID = "Facility ID",
|
|
date = "Sample collection date",
|
|
species = Contaminant,
|
|
unit = "Unit measure",
|
|
value = Result) %>%
|
|
mutate(date = as.Date(date, format = "%m/%d/%y")) %>%
|
|
readr::write_tsv(snakemake@output[[1]])
|
|
|