Skip to content
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RstoxBase
Version: 2.2.0
Date: 2026-01-29
Date: 2026-02-04
Title: Base StoX Functions
Authors@R: c(
person(given = "Arne Johannes",
Expand Down
14 changes: 13 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# RstoxBase v2.2.0-9009 (2026-01-12)
# RstoxBase v2.2.0 (2026-02-04)
* Fixed bug in RegroupLengthDistribution(), where values of IndividualTotalLength were shifted down one length interval. This problem is most apparent when the function argument LengthInterval is the same as the LengthResolution in the input LengthDistributionData. When using the GUI or RstoxFramework::runModel() and similar functions, the precision is rounded to 12 digits, which elliminates this problem for LengthResolution 1 and 0.5 cm. The following table shows the number of lengths between 0 and 1 m that are shifted down when RegroupLengthDistribution() is applied with LengthInterval equal to LengthResolution:
| LengthResolution | Fraction of values shifted down | Mean downwards shift in cm |
|----------|----------|----------|
| 0.1 mm | 357 / 1000 = 0.357 | 0.0357 |
| 0.5 mm | 7 / 200 = 0.035 | 0.0175 |
| 1 cm | 3 / 100 = 0.03 | 0.03 |

For ICESBiotic data the problem will only occur for StoX projects where data are in 1 mm resolution AND the LengthInterval in RegroupLengthDistribution is 0.1 cm. For Norwegian data the problem is potentially wider as supported length resolutions include 0.1 mm and 0.5 mm as well as 1 mm, 0.5 cm and 1 cm.
* Fixed an issue where exact matching of IndividualTotalLength and LengthResolution did not work in addLengthGroupOneSpecies(), so that the interval matching did all the work.


# RstoxBase v2.2.0-9009 (2026-02-02)
* Added the new function ReportStationsAlongTransectDesign().
* Fixed bug in PlotTransectDesign() where TrackPointColor did not work.
* Re-organized arguments of TransectDesign() to have SurveyDistance before SurveyTime, since SurveyDistance has precedence over SurveyTime.
Expand Down
4 changes: 2 additions & 2 deletions R/Abundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ addLengthGroupOneSpecies <- function(

# (1) Match the length groups exactly:
data[atSpeciesInData, TempLengthGroupUsedInSuperIndividuals := match(
paste(..lengthVar, ..resolutionVar),
paste(eval(get(lengthVar)), eval(get(resolutionVar))),
eval(
paste(
uniqueLengthGroups[[lengthVar]],
Expand Down Expand Up @@ -559,7 +559,7 @@ addLengthGroup <- function(
lengthGroupVar = "TempLengthGroupUsedInSuperIndividuals",
warn = TRUE
) {

# Run a for loop through the common species:
speciesVar <- getDataTypeDefinition(dataType = "QuantityData", subTable = "Data", elements = "categoryVariable", unlist = TRUE)
speciesInData <- unique(data[[speciesVar]])
Expand Down
2 changes: 1 addition & 1 deletion R/LengthDistribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ RegroupLengthData <- function(
lengthInterval <- getLengthInterval(LengthData, lengthInterval = lengthInterval)

# Temporary add the index of the length intervals:
LengthData[, intervalIndex := findInterval(IndividualTotalLength, ..lengthInterval)]
LengthData[, intervalIndex := findInterval_AfterRound(IndividualTotalLength, ..lengthInterval, digits = 10)]

# Get the interval widths, and count the number of hits in each interval:
lengthIntervalWidths <- diff(lengthInterval)
Expand Down
17 changes: 17 additions & 0 deletions R/Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -1799,3 +1799,20 @@ convertToNumericIfPossible <- function(x) {




#' A robust version of findInterval where the inputs are rounded off first to avoid floaring point issues
#'
#' @inheritParams base::findInterval
#' @param digits Integer: The number of digits to round \code{x} and \code{vec} to before applying \code{\link{findInterval}}.
#' @param ... Passed to \code{\link{findInterval}}.
#'
findInterval_AfterRound <- function(x, vec, digits = 10, ...) {
findInterval(
round(x, digits = digits),
round(vec, digits = digits),
...
)
}



Binary file modified inst/extdata/functionArguments.rds
Binary file not shown.
21 changes: 21 additions & 0 deletions man/findInterval_AfterRound.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.