Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q ctable test #545

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions R/Maintenance.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,32 @@ TADA_UpdateExampleData <- function() {
# # [Mozilla Developer HTTP response status codes] (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
# # Replace the broken links with functional ones or remove if no acceptable substitute is available.
# # Rerun code above to verify that df_false contains zero rows.

# # Find Characteristic/Source/Value.Unit Combinations in "WQXcharValRef.csv" with more than one row

# # open unit.ref
# unit.ref <- utils::read.csv(system.file("extdata", "WQXcharValRef.csv", package = "EPATADA")) %>%
# dplyr::filter(
# Type == "CharacteristicUnit",
# Status == "Accepted"
# )
#
# # find Characteristic/Source/Value.Unit combinations with more than one row
# find.dups <- unit.ref %>%
# dplyr::filter(Type == "CharacteristicUnit") %>%
# dplyr::group_by(Characteristic, Source, Value.Unit) %>%
# dplyr::mutate(Min_n = length(unique(Minimum)),
# Max_n = length(unique(Maximum))) %>%
# dplyr::filter(Min_n > 1 |
# Max_n > 1)
#
# # create download path
# download.path <- file.path(Sys.getenv("USERPROFILE"), "Downloads", "WQXcharValRef_multiples.csv")
#
# # create csv to send to WQX team and save in test results folder
# readr::write_csv(find.dups, download.path)
#
# # review csv and send to WQX team to update the validation table
#


4 changes: 2 additions & 2 deletions R/ResultFlagsIndependent.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ TADA_FlagAboveThreshold <- function(.data, clean = FALSE, flaggedonly = FALSE) {
"TADA.ResultMeasure.MeasureUnitCode"
),
multiple = "all",
relationship = "many-to-many"
relationship = "many-to-one"
)

# Create flag column, flag rows where ResultMeasureValue > Maximum
Expand Down Expand Up @@ -666,7 +666,7 @@ TADA_FlagBelowThreshold <- function(.data, clean = FALSE, flaggedonly = FALSE) {
"TADA.ResultMeasure.MeasureUnitCode"
),
multiple = "all",
relationship = "many-to-many"
relationship = "many-to-one"
)

# Create flag column, flag rows where TADA.ResultMeasureValue < Minimum
Expand Down
Binary file modified inst/extdata/AKAllotments.dbf
Binary file not shown.
Binary file modified inst/extdata/AKVillages.dbf
Binary file not shown.
Binary file modified inst/extdata/AmericanIndian.dbf
Binary file not shown.
Binary file modified inst/extdata/OKTribe.dbf
Binary file not shown.
Binary file modified inst/extdata/OffReservation.dbf
Binary file not shown.
Binary file modified inst/extdata/VATribe.dbf
Binary file not shown.
162 changes: 81 additions & 81 deletions inst/extdata/WQXcharValRef.csv

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions tests/testthat/test-ResultFlagsIndependent.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ test_that("TADA_FindPotentialDuplicatsMultipleOrgs has non-NA values for each ro
expect_false(any(is.na(testdat$TADA.ResultSelectedMultipleOrgs)))
})

test_that("WQXcharValRef.csv contains only one row for each unique characteristic/source/unit combination for threshold functions", {

unit.ref <- utils::read.csv(system.file("extdata", "WQXcharValRef.csv", package = "EPATADA")) %>%
dplyr::filter(
Type == "CharacteristicUnit",
Status == "Accepted"
)

find.dups <- unit.ref %>%
dplyr::filter(Type == "CharacteristicUnit") %>%
dplyr::group_by(Characteristic, Source, Value.Unit) %>%
dplyr::mutate(Min_n = length(unique(Minimum)),
Max_n = length(unique(Maximum))) %>%
dplyr::filter(Min_n > 1 |
Max_n > 1)

expect_true(nrow(find.dups) == 0)
})

test_that("range flag functions work", {
# use random data
upper <- TADA_RandomTestingData()
Expand Down
7 changes: 0 additions & 7 deletions tests/testthat/test_TADAWaterSciConWorkshopDemo.Rmd

This file was deleted.