From d6e17de54885ed19a0f2635391496903ba3fa6b3 Mon Sep 17 00:00:00 2001 From: RobFryer Date: Wed, 1 Nov 2023 18:17:10 +0000 Subject: [PATCH] Bug 354 determinand always in upper case Have ensured that the row names of info$determinand and the determinand values in ICES data extracts are all in upper case. This was already the case for external data. Have also ensured that the unit values in ICES data extracts are all in lower case (which makes it the same treatment as for external data). This needs to be revisited further down the road as TEQ derived variables do currently have upper case units. But sorting this out is low priority as TEQ variables are not in the data files. --- R/import_functions.R | 10 ++++++++++ R/information_functions.R | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/R/import_functions.R b/R/import_functions.R index 3efa6b2..7aa1a67 100644 --- a/R/import_functions.R +++ b/R/import_functions.R @@ -737,7 +737,17 @@ read_contaminants <- function(file, data_dir = ".", info) { } else { data$subseries <- NA_character_ } + + + # convert param (determinand) and munit (unit) to upper / lower case + data <- dplyr::mutate( + data, + param = toupper(.data$param), + munit = tolower(.data$munit) + ) + + return(data) } diff --git a/R/information_functions.R b/R/information_functions.R index 9e7da7a..7045c46 100644 --- a/R/information_functions.R +++ b/R/information_functions.R @@ -505,6 +505,12 @@ ctsm_read_determinand <- function( ) + + # ensure determinand is in upper case + + data$determinand <- toupper(data$determinand) + + # fill in common name if missing and create optional variables if missing data$common_name <- ifelse(