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

Develop #387

Merged
merged 2 commits into from
Oct 9, 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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RstoxData
Version: 2.0.1-9003
Date: 2024-10-04
Version: 2.0.1-9004
Date: 2024-10-08
Title: Tools to Read and Manipulate Fisheries Data
Authors@R: c(
person(given = "Edvin",
Expand Down
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# RstoxData v2.0.1-9002 (2024-09-16)
* Fixed a bug where certain lengths (the first 7 are 29, 57, 58, 113, 114, 115, 116) were shifted one cm down in ICESBiotic().
# RstoxData v2.0.1-9004 (2024-10-08)
* Fixed a bug where certain values of BiologyLengthCode were shifted one integer value down in ICESBiotic(). The bug is related to floating point precision which causes some values to be slightly lower than the corresponding integer after calculations. In R one example is format(29 / 100 * 100, digits = 20) = "28.999999999999996447", which results in 28 when converted to integer. The following values are affected:
* 29, 57, 58, 113, 114, 115, 116 when BiologyLengthCode is "cm" (lengthresolution "3")
* 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021 and 1023 when BiologyLengthCode is "mm" (lengthresolution "1")
* 1005 and 1015 (a subset of the values for "mm") when BiologyLengthCode is "halfcm" (lengthresolution "2")
* Added SpeedGround as vesselspeed from NMDBiotic in ICESBiotic().
* Fixed bug in RedefineStoxBiotic(), where duplicated keys in the input BioticData were warned but not removed.
* Added documentation of PreySpeciesCategory and PreySample in StoxBiotic.
Expand Down
12 changes: 10 additions & 2 deletions R/StoxExport.R
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,16 @@ getConversionFunction <- function(class) {
}


asIntegerAfterRound <- function(x) {
as.integer(round(x))
asIntegerAfterRound <- function(x, prec = .Machine$double.eps) {
# Convert to integer:
output <- as.integer(x)
# Find values which differ to the integer value by less than the input precision, and round these off before converting to integer to avoid occational shifts in integer value due to floating point representation (e.g. as.integer(0.29 * 100) == 28):
atSmallDiff <- which(abs(x - output) <= prec)

# Convert to integer, but for values that differ to the integer value by more than
output[atSmallDiff] <- as.integer(round(x[atSmallDiff]))

return(output)
}

#' Write ICESBiotic to CSV fille
Expand Down
Loading