Add CL data to a lower-level CS table in an RDBESDataObject
Source:R/addCLtoLowerCS.R
addCLtoLowerCS.RdThis 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 aCLtable andCSdata.- strataListCS
A named list of filter criteria for subsetting the
CSdata in theRDBESDataObject. The names of the list should match column names in any of theCStables.- strataListCL
A named list of filter criteria for subsetting the
CLdata in theRDBESDataObject. The names of the list should match column names in theCLtable.- combineStrata
Logical, if
TRUE, strata in thestrataListCSare 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
CLtable that will be summed and added as new columns to the lower-level biological data.- verbose
Logical, if
TRUE, the function prints informative text.
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.
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.
Examples
if (FALSE) { # \dontrun{
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"))
} # }