ICES Datras requires equal LngtCode and LngtClass per haul and species.

RegroupLengthICESDatras(
  ICESDatrasData,
  RegroupMethod = c("ResolutionTable", "HighestResolution"),
  ResolutionTableVariables = character(),
  ResolutionTable = data.table::data.table(),
  GroupingVariables = character(),
  AggregateHLNoAtLngt = TRUE,
  AggregationVariablesHL = character(),
  AggregateCANoAtLngt = TRUE,
  AggregationVariablesCA = character()
)

Arguments

ICESDatrasData

A ICESDatrasData object as returned from ICESDatras.

RegroupMethod

Character: A string naming the method to use, one of "ResolutionTable", for specifying a table with the desired resolutions for combinations of the ResolutionTableVariables, or "HighestResolution" to set the highest possible resolution for each combination of the GroupingVariables. In the former case, the ResolutionTableVariables must be given when the function is used in the StoX GUI, but this is not required when applied directly in R.

ResolutionTableVariables

A vector of names of the variables to use in the ResolutionTable in the GUI. Typically this could be "SpecCode".

ResolutionTable

A table of a number of columns named by variables present in both the HL and the CA, and one column named "ResolutionCode" holding desired resolution for the combinations of values in the previous columns. The values in the column "ResolutionCode" must be "1 mm", "5 mm" or "1 cm" (see getRstoxDataDefinitions("lengthCode_unit_table")$shortnameNMDBiotic). An example is data.table::data.table(SpecCode = c("126417", "126441"), ResolutionCode = c("5 mm", "1 cm")).

GroupingVariables

A vector of variable names giving the variables by which to reduce the resolution of LngtCode and LngtClass. Defaulted to "HaulNo" and "SpecCode".

AggregateHLNoAtLngt

Logical: If TRUE aggregate the variable HLNoAtLngt after regrouping lengths.

AggregationVariablesHL

A vector of variables of the HL table for which to aggregate individuals. It is recommended to use c("HaulNo", "SpecCode", "CatIdentifier", "Sex", "LngtClass"), which is the default when creating a StoX process.

AggregateCANoAtLngt

Logical: If TRUE aggregate the variable HLNoAtLngt after regrouping lengths.

AggregationVariablesCA

A vector of variables of the HL table for which to aggregate individuals. It is recommended to use c("HaulNo", "SpecCode", "LngtClass", "Sex", "Maturity", "AgeRings"), which is the default when creating a StoX process.

Value

An ICESDatrasData object.