-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtemp.R
More file actions
93 lines (75 loc) · 2.44 KB
/
temp.R
File metadata and controls
93 lines (75 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
wqs_raw_upload <- rio::import('custom_wqs_stds_2024-03-25.xlsx') %>% janitor::clean_names()
user_data_list$upload <- rio::import('curated_user_data_2024-04-23.xlsx')
if('preferredName' %in% colnames(user_data_list$upload) && 'dtxsid' %in% colnames(user_data_list$upload)){
TRUE}else{FALSE}
# RAIS --------------------------------------------------------------------
rais <- rio::import(list.files(pattern = 'rais_curated_'), trust = T) %>%
mutate(
enduse = 'Screening',
subsource = NA_character_
) %>%
rename(
Name = preferredName
)
# Cust --------------------------------------------------------------------
cust_stds <- rio::import(
list.files(pattern = 'custom_wqs_stds_'), na.strings=c(""," ","NA")) %>%
clean_names() %>%
rename(
dtxsid = final,
Name = preferred_name
)
# SSWQS -------------------------------------------------------------------
sswqs <- rio::import(
list.files(pattern =
'sswqs_curated_'), trust = TRUE
) %>%
mutate(
criterion_id = as.numeric(criterion_id),
criterion_id = paste0('sswqs_', criterion_id),
subsource = 'SSWQS',
origin_category = 'State',
priority_id = 1,
data_category = 'primary',
media = 'Surface water'
) %>%
rename(
Name = preferredName,
# criterion_value = crit_val_conv,
)
# benchmarks --------------------------------------------------------------
benchmarks <- list_rbind(
list(
sswqs = sswqs,
cust_stds = cust_stds,
#ccd = hazard,
rais = rais
), names_to = 'data_source') %>%
mutate(
criterion_value = case_when(
unit_name == 'ug/l' ~ criterion_value/1000,
unit_name == 'ug/L' ~ criterion_value/1000,
unit_name == 'ng/l' ~ criterion_value/1e-6
,.default = criterion_value),
unit_name = case_when(
unit_name == 'ug/L' ~ 'mg/l',
unit_name == 'ug/l' ~ 'mg/l',
unit_name == 'ng/l' ~ 'mg/l',
unit_name == 'ng/L' ~ 'mg/l',
unit_name == 'mg/L' ~ 'mg/l'
,.default = unit_name),
protection = case_when(
is.na(protection) ~ 'UNC',
protection == 'Human' ~ 'Human health',
protection == 'human health' ~ 'Human health',
protection == 'eco' ~ 'Ecological'
,.default = protection),
media = case_when(
is.na(media) ~ 'UNC',
media == 'SurfaceWater' ~ 'Surface water'
,.default = media
),
priority_id = case_when(
source == 'RSL' ~ 3
,.default = priority_id)
)