Skip to content

Commit 2f74e83

Browse files
committed
Add filter for units for each particular parameter. Also keep NA units
1 parent cb54988 commit 2f74e83

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

R/process.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ format_results <- function(df){
4242

4343
process_wq <- function(df, start_date, end_date){
4444

45-
# Filter data for target locations and parameters and target date range
45+
# Filter data for target locations, parameters, units, and target date range
4646
loc_id <- location_id$location_id
47-
params <- c("Conductivity", "Dissolved oxygen (DO)", "Escherichia coli", "pH", "Phosphorus, Total (as P)", "Nitrogen", "Temperature, water", "Turbidity")
47+
params <- c("Conductivity", "Dissolved oxygen (DO)", "Escherichia coli", "Nitrogen", "pH", "Phosphorus, Total (as P)", "Temperature, water", "Turbidity")
48+
param_units <- c("uS/cm", "mg/l", "MPN/100mL", "mg/l", "none", "mg/l", "deg C", "NTU")
4849

4950
df_processed <- df %>%
5051
dplyr::filter(location_format %in% loc_id,
51-
Analyte %in% params,
52+
Analyte %in% params & (Unit %in% param_units | is.na(Unit)), # Filter the data for the list of parameters, units, and also include rows with NA in the Unit column
5253
qualifier_format != "?",
5354
date_format >= start_date & date_format <= end_date)
5455

workflow.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ devtools::load_all(".")
5050
df_wq <- readxl::read_excel("data/ARII_Xtab_AmbWQ_SCI.xlsx")
5151

5252

53-
start_date <- "2018-07-01"
54-
end_date <- "2023-06-30"
53+
start_date <- "2015-07-01"
54+
end_date <- "2020-06-30"
5555

5656
df_wq_formatted <- format_results(df_wq)
5757
df_wq_processed <- process_wq(df_wq_formatted, start_date, end_date)

0 commit comments

Comments
 (0)