Skip to content

Commit a8db053

Browse files
Merge pull request #425 from StoXProject/StoXv4.1.0
Corrected error in HLNoAtLngt in ICESDatras().
2 parents 1e1f72d + 0458d42 commit a8db053

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: RstoxData
2-
Version: 2.1.4-9001
3-
Date: 2025-03-21
2+
Version: 2.1.4-9002
3+
Date: 2025-03-26
44
Title: Tools to Read and Manipulate Fisheries Data
55
Authors@R: c(
66
person(given = "Edvin",

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# RstoxData v2.1.4-9002 (2025-03-26)
2+
* Corrected error in ICESDatras() where HLNoAtLngt was not properly set (Sex set to NA after HLNoAtLngt was calculated).
3+
4+
15
# RstoxData v2.1.4-9001 (2025-03-21)
26
* Changed ICESDatras() to output missing Sex in the HL table, and where TotalNo and NoMeas are now sums over all sexes (a consequence of setting Sex to NA). The reason for this change is that in Norwegian biotic data catch categories (sub-samples) are not separated by sex, which results in SubWgt and CatCatchWgt being sums over sexes. In other words, the resolution in the Norwegian biotic data is not by sex, hence the change to Sex set to NA in the HL table. The CA table is left unchanged.
37

R/StoxExport.R

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,21 +1226,32 @@ ICESDatrasOne <- function(
12261226
### mergedHL[lenInterval == interval, lngtClass := intVec[findInterval(length, intVec)]]
12271227
### }
12281228

1229+
1230+
12291231
# Count measured individual
12301232
mergedHL[!is.na(length), lsCountTot := 1]
12311233

1232-
# Aggregate hlNoAtLngth and lsCountTot
1233-
finalHL <- mergedHL[, .(N, lsCountTot = sum(lsCountTot)), by = c(
1234-
groupHL,
1235-
"lngtClass", "Quarter", "Country", "Ship", "Gear", "SweepLngt", "GearEx", "DoorType", "HaulNo", "SpecVal", "catCatchWgt", "sampleFac", "subWeight", "lngtCode", "stationtype", "lengthmeasurement"
1236-
)
1237-
]
12381234

12391235
# To fix the problem that the procedure at the IMR is to not split sex into different subsamples, we set the sex to NA here, so that aggregation to produce noMeas and totalNo sum over sexes. The reason for this is that catCatchWgt and subWeight are in practice summed over sexes, and we do not want to do estimation to split these by sex.
1236+
finalHL <- mergedHL
12401237
finalHL[, sex := NA]
12411238

1239+
# Aggregate hlNoAtLngth and lsCountTot
1240+
# We ignore the defined aggregation variable devstage, as this is always NA in norwegian data (hard coded below):
1241+
finalHL <- finalHL[, lsCountTot := sum(lsCountTot), by = c(groupHL, "lngtClass")]
1242+
finalHL <- unique(finalHL, by = c(groupHL, "lngtClass"))
1243+
1244+
#finalHL <- finalHL[, .(N, lsCountTot = sum(lsCountTot)), by = c(
1245+
# groupHL,
1246+
# "lngtClass", "Quarter", "Country", "Ship", "Gear", "SweepLngt", "GearEx", "DoorType", "HaulNo", "SpecVal", "catCatchWgt", "sampleFac", "subWeight", "lngtCode", "stationtype", "lengthmeasurement"
1247+
# )
1248+
#]
1249+
1250+
# To fix the problem that the procedure at the IMR is to not split sex into different subsamples, we set the sex to NA here, so that aggregation to produce noMeas and totalNo sum over sexes. The reason for this is that catCatchWgt and subWeight are in practice summed over sexes, and we do not want to do estimation to split these by sex.
1251+
#finalHL[, sex := NA]
1252+
12421253

1243-
finalHL <- finalHL[!duplicated(finalHL)]
1254+
#finalHL <- finalHL[!duplicated(finalHL)]
12441255
finalHL[,`:=`(noMeas = sum(lsCountTot)), by = groupHL]
12451256
finalHL[,`:=`(totalNo = noMeas * sampleFac, subFactor = sampleFac)]
12461257

0 commit comments

Comments
 (0)