Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b9b9e5
changes to harmonization and unit tables
hillarymarler Jul 2, 2025
dde68da
add file from MT
hillarymarler Jul 3, 2025
c18492e
updates to TADA_UniqueCharUnitSpeciation and harmonization tables
hillarymarler Jul 8, 2025
4a29623
Update HarmonizationTemplate.csv
hillarymarler Jul 8, 2025
9c466f7
Update UnitConversions.R
hillarymarler Jul 11, 2025
4244e4f
Update UnitConversions.R
hillarymarler Jul 11, 2025
43a61fb
Merge branch 'develop' into MT_troubleshooting
hillarymarler Jul 14, 2025
0c13b22
Update UnitConversions.R
hillarymarler Jul 14, 2025
7e658f3
Update UnitConversions.R
hillarymarler Jul 14, 2025
6ad56ee
Update UnitConversions.R
hillarymarler Jul 14, 2025
363619f
Update UnitConversions.R
hillarymarler Jul 14, 2025
9219e59
Update UnitConversions.R
hillarymarler Jul 14, 2025
5ac1f2f
Update UnitConversions.R
hillarymarler Jul 14, 2025
2b1a051
Update UnitConversions.R
hillarymarler Jul 14, 2025
d6176d5
Update UnitConversions.R
hillarymarler Jul 14, 2025
b7ae004
Update UnitConversions.R
hillarymarler Jul 14, 2025
ec353b5
updates
hillarymarler Jul 14, 2025
9b93956
dim check bug fix
hillarymarler Jul 15, 2025
477830d
Update UnitConversions.R
hillarymarler Jul 15, 2025
4d7de6c
Update UnitConversions.R
hillarymarler Jul 15, 2025
de7cecd
Update UnitConversions.R
hillarymarler Jul 15, 2025
4f6cd90
Update UnitConversions.R
hillarymarler Jul 15, 2025
64c5221
Update UnitConversions.R
hillarymarler Jul 15, 2025
fe0eb27
Update UnitConversions.R
hillarymarler Jul 15, 2025
f105dd4
remove test files, final rm updates from UnitConversion
hillarymarler Jul 15, 2025
be075d2
Merge branch 'develop' into MT_troubleshooting
hillarymarler Jul 15, 2025
68f03ff
Update .gitignore
hillarymarler Jul 15, 2025
74cfa14
fix conversion issues
hillarymarler Jul 15, 2025
d70f6a4
Update CensoredDataSuite.R
hillarymarler Jul 15, 2025
4670108
Update CensoredDataSuite.R
hillarymarler Jul 16, 2025
2d931a9
Update CensoredDataSuite.R
hillarymarler Jul 16, 2025
49f219a
Update CensoredDataSuite.R
hillarymarler Jul 17, 2025
aa24ba3
Update CensoredDataSuite.R
hillarymarler Jul 17, 2025
1a1e6dc
Update WQXProviderRef.csv
hillarymarler Jul 21, 2025
0bb8bc0
Update UnitConversions.R
hillarymarler Jul 22, 2025
e1367c5
update harmonization template and priority char unit ref
cristinamullin Jul 25, 2025
27ad30c
remove unit conversion from TADA_HarmonizeSynonyms
cristinamullin Jul 25, 2025
8d092c4
do not eval geospatial Rmd, update description
cristinamullin Jul 28, 2025
b49df90
Update DESCRIPTION
cristinamullin Jul 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ Imports:
igraph,
jsonlite,
openxlsx,
rExpertQuery,
DT,
dataRetrieval,
dbscan,
janitor
janitor,
rExpertQuery
Depends:
R (>= 3.5.0)
Suggests:
StreamCatTools,
hydroloom,
lwgeom,
RColorBrewer,
Expand All @@ -104,9 +103,7 @@ Suggests:
rvest,
remotes
Remotes:
DOI-USGS/dataRetrieval@develop,
USEPA/rExpertQuery@develop,
USEPA/StreamCatTools@master
USEPA/rExpertQuery@develop
VignetteBuilder: knitr, rmarkdown
Language: en-US
Config/testthat/edition: 3
Expand Down
30 changes: 27 additions & 3 deletions R/CensoredDataSuite.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ TADA_IDCensoredData <- function(.data) {
#' )
#' }
#'
TADA_SimpleCensoredMethods <- function(.data, nd_method = "multiplier", nd_multiplier = 0.5, od_method = "as-is", od_multiplier = "null") {
TADA_SimpleCensoredMethods <- function(.data, nd_method = "multiplier",
nd_multiplier = 0.5,
od_method = "as-is",
od_multiplier = "null") {
# check .data has all of the required columns
expected_cols <- c(
"ResultDetectionConditionText",
Expand Down Expand Up @@ -337,7 +340,13 @@ TADA_SimpleCensoredMethods <- function(.data, nd_method = "multiplier", nd_multi
# split out over detects and non detects
nd <- subset(cens.data, cens.data$TADA.CensoredData.Flag == "Non-Detect")
od <- subset(cens.data, cens.data$TADA.CensoredData.Flag == "Over-Detect")
all_others <- subset(cens.data, !cens.data$ResultIdentifier %in% c(nd$ResultIdentifier, od$ResultIdentifier))
no.ref <- subset(cens.data, cens.data$TADA.CensoredData.Flag == "Detection condition is missing and required for censored data ID.")
missing.ref <- subset(cens.data, cens.data$TADA.CensoredData.Flag == "Detection condition or detection limit is not documented in TADA reference tables.")

all_others <- subset(cens.data, !cens.data$ResultIdentifier %in% c(nd$ResultIdentifier, od$ResultIdentifier,
no.ref$ResultIdentifier, missing.ref$ResultIdentifier))

# HRM note 7/15/2025 still need to add code to set no.ref.missing results to NA

# ND handling
if (dim(nd)[1] > 0) {
Expand Down Expand Up @@ -369,7 +378,22 @@ TADA_SimpleCensoredMethods <- function(.data, nd_method = "multiplier", nd_multi
}
}

.data <- plyr::rbind.fill(nd, od, all_others) %>%
# handling for results with missing detection conditions or with a detection condition or limit not in TADA ref table
if (dim(no.ref)[1] > 0) {
no.ref$TADA.ResultMeasureValue <- NA
no.refTADA.CensoredMethod <- "Result set to NA due to Missing Detection Condition"
no.ref$TADA.ResultMeasureValueDataTypes.Flag <- "Result Value/Unit Cannot Be Estimated From Detection Limit"
}

# handling for results with missing detection conditions or with a detection condition or limit not in TADA ref table
if (dim(missing.ref)[1] > 0) {
missing.ref$TADA.ResultMeasureValue <- NA
missing.ref$TADA.CensoredMethod <- "Result set to NA as Detection Conditon or Limit is not in TADA Ref Table"
missing.ref$TADA.ResultMeasureValueDataTypes.Flag <- "Result Value/Unit Cannot Be Estimated From Detection Limit"
}


.data <- plyr::rbind.fill(nd, od, all_others, no.ref, missing.ref) %>%
TADA_CreateComparableID()
}
.data <- TADA_OrderCols(.data)
Expand Down
14 changes: 7 additions & 7 deletions R/Transformations.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' synonym table created from TADA_GetSynonymRef and reviewed/customized by the
#' user (recommended), or the default TADA-provided synonym table, containing
#' suggested synonym naming for some priority characteristics. Where a suggested
#' characteristic name, fraction, speciation, or unit is present, the function
#' characteristic name, fraction, or speciation is present, the function
#' will convert the TADA.CharacteristicName, TADA.ResultSampleFractionText,
#' and TADA.MethodSpeciationName to the target format. In cases where a target
#' speciation differs from the existing speciation, the reference table will
Expand All @@ -24,8 +24,8 @@
#' NO3 will be converted to as N using molecular weight conversion factors.
#'
#' @return The input TADA dataframe with the TADA.CharacteristicName,
#' TADA.ResultSampleFractionText, TADA.MethodSpeciationName, and
#' TADA.ResultMeasure.MeasureUnitCode columns converted to the target values,
#' TADA.ResultSampleFractionText, and TADA.MethodSpeciationName columns
#' converted to the target values,
#' if supplied. Also includes additional columns
#' TADA.CharacteristicNameAssumptions, TADA.FractionAssumptions, and
#' TADA.SpeciationAssumptions populated with additional notes about the conversion
Expand Down Expand Up @@ -94,11 +94,11 @@ TADA_HarmonizeSynonyms <- function(.data, ref, np_speciation = TRUE) {
stop("TADA.ResultMeasureValue is not numeric. This column must be numeric before proceeding.")
}

# Change NONE in unit, fraction, and speciation to NA for better harmonization
# Changes NONE in fraction and speciation to NA for better harmonization
# Should this be specified in the template instead? 7/25/25 cm
Copy link
Collaborator

@cristinamullin cristinamullin Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TADA_HarmonizeSynonyms was still changing NONE back to NA for PH units. Removed this line here so it is now resolving to
"PH_NONE_NONE_NONE"

The functions still changes NONE in fraction and speciation to NA for better harmonization as a generalized solution. For pH and DO, NONE is specified in the template so that overrides the generalized solution for those two. Does that still make sense as a generalized solution for all others not specified in the harmonization template... or should these lines be removed and everything done in the template (lots more rows we would need to add...)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hillarymarler this has already been merged, but can you double check the logic?

.data <- .data %>% dplyr::mutate(
TADA.ResultSampleFractionText = replace(TADA.ResultSampleFractionText, TADA.ResultSampleFractionText %in% c("NONE"), NA),
TADA.MethodSpeciationName = replace(TADA.MethodSpeciationName, TADA.MethodSpeciationName %in% c("NONE"), NA),
TADA.ResultMeasure.MeasureUnitCode = replace(TADA.ResultMeasure.MeasureUnitCode, TADA.ResultMeasure.MeasureUnitCode %in% c("NONE"), NA)
TADA.MethodSpeciationName = replace(TADA.MethodSpeciationName, TADA.MethodSpeciationName %in% c("NONE"), NA)
)

# define harm.ref
Expand Down Expand Up @@ -313,7 +313,7 @@ TADA_CalculateTotalNP <- function(.data, sum_ref, daily_agg = c("max", "min", "m
"ActivityMediaSubdivisionName",
"TADA.ActivityMediaName",
"TADA.ComparableDataIdentifier",
"TADA.ResultMeasure.MeasureUnitCode",
# "TADA.ResultMeasure.MeasureUnitCode",
depths
)

Expand Down
Loading
Loading