addCLtoLowerCS: Add CL data to a lower-level CS table in an RDBESDataObject

View source: R/addCLtoLowerCS.R

addCLtoLowerCSR Documentation

Add CL data to a lower-level CS table in an RDBESDataObject

Description

This function adds data from a CL table in an RDBESDataObject to a BV or FM table. It combines information from the CS and CL tables and calculates aggregate statistics such as the sum of the specified fields in the CL table.

Usage

addCLtoLowerCS(
  rdbes,
  strataListCS,
  strataListCL,
  combineStrata = T,
  lowerHierarchy = "C",
  CLfields = c("CLoffWeight"),
  verbose = FALSE
)

Arguments

rdbes

An object of class RDBESDataObject. This object contains tables from the RDBES data structure, including a CL table and CS data.

strataListCS

A named list of filter criteria for subsetting the CS data in the RDBESDataObject. The names of the list should match column names in any of the CS tables.

strataListCL

A named list of filter criteria for subsetting the CL data in the RDBESDataObject. The names of the list should match column names in the CL table.

combineStrata

Logical, if TRUE, strata in the strataListCS are combined using a vertical bar (|).

lowerHierarchy

A character string specifying the level of the lower hierarchy table to which the CL data will be added. Currently, only "C" is supported ie BV data only.

CLfields

A character vector of field names from the CL table that will be summed and added as new columns to the lower-level biological data.

verbose

Logical, if TRUE, the function prints informative text.

Details

The function first subsets the biological data in the RDBESDataObject based on the criteria in strataListCS. It then retrieves the corresponding CL data based on the criteria in strataListCL, sums the fields specified in CLfields, and adds them as new columns to the biological data. If combineStrata is TRUE, strata columns from the CS data are collapsed using a vertical bar (|). The function currently supports only biological data at the "C" hierarchy level.

Value

A data.table containing the biological data from the lower hierarchy with added strata information from the CL table and the sum of the specified fields from the CL data.

See Also

getLowerTableSubsets, upperTblData

Examples

## Not run: 
strataListCS <- list(LEarea="27.3.d.28.1",
                     LEmetier6 = "OTM_SPF_16-31_0_0",
                     TEstratumName = month.name[1:3],
                     SAspeCodeFAO = "SPR")
strataListCL <- list(CLarea="27.3.d.28.1",
                     CLquar = 1,
                     CLmetier6 = "OTM_SPF_16-31_0_0",
                     CLspecFAO = "SPR")
biolCL <- addCLtoLowerCS(rdbesObject, strataListCS, strataListCL,
                         combineStrata = TRUE,
                         lowerHierarchy = "C",
                         CLfields = c("CLoffWeight"))

## End(Not run)


ices-tools-dev/icesRDBES documentation built on April 17, 2025, 1:58 p.m.