Skip to content

Commit

Permalink
Merge pull request #357 from morungos/validate-uncertainty
Browse files Browse the repository at this point in the history
Add uncertainty validation for external
  • Loading branch information
RobFryer authored Nov 6, 2023
2 parents a4e1849 + 4fd4ec3 commit 34919df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/import_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,18 @@ read_contaminants <- function(file, data_dir = ".", info) {
colClasses = var_id[ok]
)

# additional validations

# every valid `uncertainty` must have a valid `unit_uncertainty`
uncertainty_present <- which(complete.cases(data$uncertainty))
uncertainty_present_valid_units <-
data$unit_uncertainty[uncertainty_present] %in% c("%", "U2", "SD")
if (! all(uncertainty_present_valid_units)) {
stop(
"Missing or invalid uncertainty units for specified uncertainty values. ",
"Please check that all uncertainty values have a valid unit: %, U2, or SD"
)
}
}


Expand Down

0 comments on commit 34919df

Please sign in to comment.