Skip to content

Commit

Permalink
Merge pull request #389 from RobFryer/bug_388
Browse files Browse the repository at this point in the history
  • Loading branch information
morungos authored Dec 7, 2023
2 parents 0cfa4cc + 3f1a83c commit 966bad8
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions R/import_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -910,18 +910,6 @@ 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 Expand Up @@ -969,7 +957,24 @@ read_contaminants <- function(file, data_dir = ".", info) {
}




# additional validations (for external data)

if (info$data_format == "external") {

# 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"
)
}
}


# check regional identifiers are in the extraction

# if (info$data_format == "ICES_old") {
Expand Down

0 comments on commit 966bad8

Please sign in to comment.