Skip to content

Commit aca7e25

Browse files
committed
v1.2.4.9004
* refactor: Add new fish ageclass metrics, Issue #129 * tests: Update fish tests with new column, ageclass
1 parent 1a07207 commit aca7e25

7 files changed

Lines changed: 70 additions & 9 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: BioMonTools
22
Type: Package
33
Title: Biomonitoring and Bioassessment Calculations
4-
Version: 1.2.4.903
4+
Version: 1.2.4.9004
55
Authors@R: c(
66
person("Erik W.", "Leppo",
77
email="Erik.Leppo@tetratech.com",

NEWS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ NEWS
44

55
<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->
66

7-
#> Last Update: 2025-12-15 12:16:15.035087
7+
#> Last Update: 2025-12-26 15:31:28.075211
88

99
# Version History
1010

11+
## Changes in version 1.2.4.9004 (2025-12-26)
12+
13+
- refactor: Add new fish ageclass metrics, Issue \#129
14+
- tests: Update fish tests with new column, ageclass
15+
1116
## Changes in version 1.2.4.9003 (2025-12-15)
1217

1318
- refactor: Update MetricScoring.xlsx for EGLE_2025 (MI)

NEWS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ NEWS
44

55
<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->
66

7-
#> Last Update: 2025-12-15 12:16:15.035087
7+
#> Last Update: 2025-12-26 15:31:28.075211
88

99
# Version History
1010

11+
## Changes in version 1.2.4.9004 (2025-12-26)
12+
13+
- refactor: Add new fish ageclass metrics, Issue \#129
14+
- tests: Update fish tests with new column, ageclass
15+
1116
## Changes in version 1.2.4.9003 (2025-12-15)
1217

1318
- refactor: Update MetricScoring.xlsx for EGLE_2025 (MI)

NEWS.rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ cat(paste0("Last Update: ",Sys.time()))
1818

1919
# Version History
2020

21+
## Changes in version 1.2.4.9004 (2025-12-26)
22+
23+
* refactor: Add new fish ageclass metrics, Issue #129
24+
* tests: Update fish tests with new column, ageclass
25+
2126
## Changes in version 1.2.4.9003 (2025-12-15)
2227

2328
* refactor: Update MetricScoring.xlsx for EGLE_2025 (MI)

R/metric_values.R

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,7 +3758,7 @@ metric.values.fish <- function(myDF
37583758
, "BCG_ATTR2")
37593759
col.req_logical <- c("EXCLUDE", "HYBRID")
37603760
col.req_numeric <- c("N_TAXA", "N_ANOMALIES", "SAMP_BIOMASS", "DA_MI2"
3761-
, "SAMP_WIDTH_M", "SAMP_LENGTH_M", "TOLVAL2"
3761+
, "SAMP_WIDTH_M", "SAMP_LENGTH_M", "TOLVAL2", "AGECLASS"
37623762
)
37633763
col.req <- c(col.req_character, col.req_logical, col.req_numeric)
37643764
# col.req <- c("SAMPLEID", "TAXAID", "N_TAXA", "EXCLUDE"
@@ -4481,6 +4481,7 @@ metric.values.fish <- function(myDF
44814481
, nt_natCent = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & FAMILY == "CENTRARCHIDAE"], na.rm = TRUE)
44824482
, nt_natinsctCypr = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" &
44834483
TROPHIC_IS == TRUE & FAMILY == "CYPRINIDAE"], na.rm = TRUE)
4484+
, nt_natLeuc = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & FAMILY == "LEUCISCIDAE"], na.rm = TRUE)
44844485
, nt_natrbs = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & NATIVE == "NATIVE" & TYPE == "RBS"], na.rm = TRUE)
44854486
, nt_Petro = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "PETROMYZONTIDAE"], na.rm = TRUE)
44864487
, nt_Salm = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & FAMILY == "SALMONIDAE"], na.rm = TRUE)
@@ -4539,6 +4540,10 @@ metric.values.fish <- function(myDF
45394540
, nt_invertivore = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE
45404541
& TROPHIC_IV == TRUE]
45414542
, na.rm = TRUE)
4543+
, nt_invert_native = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE
4544+
& TROPHIC_IV == TRUE
4545+
& NATIVE == "NATIVE"]
4546+
, na.rm = TRUE)
45424547
, nt_inverttopcarn = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE
45434548
& TROPHIC_IV_TC == TRUE]
45444549
, na.rm = TRUE)
@@ -4570,6 +4575,7 @@ metric.values.fish <- function(myDF
45704575
, pi_insctCypr = 100 * sum(N_TAXA[TROPHIC_IS == TRUE &
45714576
FAMILY == "CYPRINIDAE"], na.rm = TRUE) / ni_total
45724577
, pi_invertivore = 100 * sum(N_TAXA[TROPHIC_IV == TRUE], na.rm = TRUE) / ni_total
4578+
, pi_invert_native = 100 * sum(N_TAXA[TROPHIC_IV == TRUE & NATIVE == "NATIVE"], na.rm = TRUE) / ni_total
45734579
, pi_inverttopcarn = 100 * sum(N_TAXA[TROPHIC_IV_TC == TRUE], na.rm = TRUE) / ni_total
45744580
, pi_omnivore = 100 * sum(N_TAXA[TROPHIC_OM == TRUE], na.rm = TRUE) / ni_total
45754581
, pi_planktivore = 100 * sum(N_TAXA[TROPHIC_PL == TRUE], na.rm = TRUE) / ni_total
@@ -4584,17 +4590,24 @@ metric.values.fish <- function(myDF
45844590
, pt_detritivore = 100 * nt_detritivore / nt_total
45854591
, pt_herbivore = 100 * nt_herbivore / nt_total
45864592
, pt_invertivore = 100 * nt_invertivore / nt_total
4593+
, pt_invert_native = 100 * nt_invert_native / nt_total
45874594
, pt_inverttopcarn = 100 * nt_inverttopcarn / nt_total
45884595
, pt_omnivore = 100 * nt_omnivore / nt_total
45894596
, pt_planktivore = 100 * nt_planktivore / nt_total
45904597
, pt_topcarn = 100 * nt_topcarn / nt_total
45914598

45924599
#
45934600
## Tolerance ####
4594-
, nt_tv_intol = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & TOLER == "INTOLERANT"], na.rm = TRUE)
4595-
, nt_tv_intolhwi = dplyr::n_distinct(TAXAID[EXCLUDE != TRUE & (TOLER == "INTOLERANT" |
4596-
TOLER == "HWI")], na.rm = TRUE)
4597-
, pi_tv_toler = 100 * sum(N_TAXA[TOLER == "TOLERANT"], na.rm = TRUE) / ni_total
4601+
, nt_tv_intol = dplyr::n_distinct(
4602+
TAXAID[EXCLUDE != TRUE & TOLER == "INTOLERANT"],
4603+
na.rm = TRUE)
4604+
, nt_tv_intolhwi = dplyr::n_distinct(
4605+
TAXAID[EXCLUDE != TRUE &
4606+
(TOLER == "INTOLERANT" | TOLER == "HWI")],
4607+
na.rm = TRUE)
4608+
, pi_tv_toler = 100 *
4609+
sum(N_TAXA[TOLER == "TOLERANT"], na.rm = TRUE) /
4610+
ni_total
45984611
#
45994612

46004613

@@ -5069,7 +5082,7 @@ metric.values.fish <- function(myDF
50695082
, na.rm = TRUE) / ni_total
50705083
, pi_repro_migratory = 100 * sum(N_TAXA[REPRO_MIG == TRUE]
50715084
, na.rm = TRUE) / ni_total
5072-
, pi_repro_lithophil = 100 * sum(N_TAXA[REPRO_LITH == TRUE]
5085+
, pi_repro_lithophil = 100 * sum(N_TAXA[REPRO_LITH == TRUE]
50735086
, na.rm = TRUE) / ni_total
50745087

50755088
### Repro, pt ----
@@ -5107,6 +5120,35 @@ metric.values.fish <- function(myDF
51075120
, pt_habitat_w = 100 * nt_habitat_w / nt_total
51085121
, pt_habitat_f = 100 * nt_habitat_f / nt_total
51095122

5123+
## Age Class ----
5124+
# Young of Year, YOY is ageclass 1 or 2
5125+
, d_ac_yoy_Cott = max(0,
5126+
min(1,
5127+
dplyr::n_distinct(
5128+
TAXAID[(EXCLUDE != TRUE &
5129+
FAMILY == "COTTIDAE") &
5130+
(AGECLASS == 1 |
5131+
AGECLASS == 2)],
5132+
na.rm = TRUE),
5133+
na.rm = TRUE),
5134+
na.rm = TRUE)
5135+
, d_ac_yoy_rbt = max(0,
5136+
min(1,
5137+
dplyr::n_distinct(
5138+
TAXAID[(EXCLUDE != TRUE &
5139+
TAXAID == "ONCORHYNCHUS MYKISS") &
5140+
(AGECLASS == 1 |
5141+
AGECLASS == 2)],
5142+
na.rm = TRUE),
5143+
na.rm = TRUE),
5144+
na.rm = TRUE)
5145+
, n_ac_Cott = dplyr::n_distinct(AGECLASS[EXCLUDE != TRUE &
5146+
FAMILY == "COTTIDAE"],
5147+
na.rm = TRUE)
5148+
, n_ac_rbt = dplyr::n_distinct(AGECLASS[EXCLUDE != TRUE &
5149+
TAXAID == "ONCORHYNCHUS MYKISS"],
5150+
na.rm = TRUE)
5151+
51105152
## SPECIAL ----
51115153
# odd ball metrics that don't fit the above groupings
51125154
# OR are really different and probably only applicable

inst/extdata/MetricNames.xlsx

1.55 KB
Binary file not shown.

tests/testthat/test_metric_names.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ testthat::test_that("metric.values, names, fish, Function, xlNames", {
224224
# Munge (v1.0.2.9015, 2024-04-29)
225225
df_fish$TOLVAL2 <- NA_integer_
226226
df_fish$BCG_ATTR2 <- NA_character_
227+
# 2025-12-26
228+
df_fish$AGECLASS <- c(NA, 1:10)
227229

228230
# Function
229231
df_metval <- BioMonTools::metric.values(df_fish
@@ -312,6 +314,8 @@ testthat::test_that("metric.values, names, fish, Function, xlScoring", {
312314
# Munge (v1.0.2.9015, 2024-04-29)
313315
df_fish$TOLVAL2 <- NA_integer_
314316
df_fish$BCG_ATTR2 <- NA_character_
317+
# 2025-12-26
318+
df_fish$AGECLASS <- c(NA, 1:10)
315319

316320
# Function
317321
df_metval <- BioMonTools::metric.values(df_fish

0 commit comments

Comments
 (0)