From 261f6af5a345cceb7cb5bcbab7312164ed3c1f0d Mon Sep 17 00:00:00 2001 From: hillarymarler Date: Tue, 5 Dec 2023 12:48:12 -0500 Subject: [PATCH 1/2] Update Utilities.R --- R/Utilities.R | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/R/Utilities.R b/R/Utilities.R index 26944731..ad206d37 100644 --- a/R/Utilities.R +++ b/R/Utilities.R @@ -624,9 +624,23 @@ TADA_OrderCols <- function(.data) { TADA_SubstituteDeprecatedChars <- function(.data) { TADA_CheckColumns(.data, expected_cols = c("CharacteristicName", "TADA.CharacteristicName")) - # read in characteristic reference table with deprecation information and filter to deprecated terms - ref.table <- TADA_GetCharacteristicRef() %>% dplyr::filter(Char_Flag == "Deprecated") - + # read in characteristic reference table with deprecation information, filter to deprecated terms and for "retired" in CharactersticName. + # remove all characters after first "*" in CharacteristicName and remove any leading or trailing white space to make compatible with deprecated NWIS CharactersticName. + nwis.table <- TADA_GetCharacteristicRef() %>% + dplyr::filter( + Char_Flag == "Deprecated", + grepl("retired", CharacteristicName) + ) %>% + dplyr::mutate(CharacteristicName = trimws(stringr::str_split(CharacteristicName, "\\*", simplify = T)[, 1])) + + # read in characteristic reference table with deprecation information and filter to deprecated terms. + # join with deprecated NWIS CharacteristicName data.frame. + ref.table <- TADA_GetCharacteristicRef() %>% + dplyr::filter(Char_Flag == "Deprecated") %>% + rbind(nwis.table) + + rm(nwis.table) + # merge to dataset .data <- merge(.data, ref.table, all.x = TRUE) # if CharacteristicName is deprecated and comparable name is not BLANK, use the provided Comparable.Name. Otherwise, keep TADA.CharacteristicName as-is. From 101080fd76bee105600b742d1dad7ab5a390b20b Mon Sep 17 00:00:00 2001 From: hillarymarler Date: Thu, 7 Dec 2023 10:48:42 -0500 Subject: [PATCH 2/2] Update Utilities.R --- R/Utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Utilities.R b/R/Utilities.R index ad206d37..e743af6f 100644 --- a/R/Utilities.R +++ b/R/Utilities.R @@ -611,7 +611,7 @@ TADA_OrderCols <- function(.data) { #' in TADA_BigDataRetrieval. Therefore, deprecated characteristic names are #' harmonized to their current name automatically upon data retrieval. #' TADA_SubstituteDeprecatedChars can also be used by itself on a user supplied -#' dataset that is in the WQX format, if desired. +#' dataset that is in the WQX format, if desired. This solution works for both EPA WQX and USGS NWIS provided data. #' #' @param .data TADA dataframe #'