Landings data analysed to determine NEGEAR aggregation, MARKET_CODE descriptions analysed over time to determine aggregation all subject to length sample availability. Output document created and a logfile to inform the user what steps were taken during aggregation

aggregate_landings(
  channel,
  landingsData,
  lengthData,
  speciesName = NULL,
  landingsThresholdGear = 0.9,
  nLengthSamples = 1,
  pValue = 0.05,
  aggregate_to = "YEAR",
  borrowLengths = T,
  proportionMissing = 0.2,
  otherGear = "998",
  outputDir = here::here("output"),
  outputPlots = F,
  logfile = "logFile.txt",
  speciesRules = NULL
)

Arguments

channel

an Object inherited from DBIConnection-class. This object is used to communicate with the database engine. (see connect_to_database)

landingsData

Tidy data frame. Landings by YEAR,QTR,NEGEAR,MARKET_CODE,landings_land,landings_nn,len_totalNumLen,len_numLengthSampls

lengthData

Tidy data frame. Length data by YEAR,QTR,NEGEAR,MARKET_CODE, LENGTH, NUMLEN

speciesName

Character string. speciesName for data used. (This is used in plotting only)

landingsThresholdGear

Numeric scalar (proportion). Minimum proportion of cumulative landings to avoid aggregation of gear. Default = .9

nLengthSamples

Numeric scalar. The minimum number of length sample sizes required to avoid combination of data. Default = 1

pValue

Numeric scalar. Threshold pvalue for determining significance of ks test for length samples

aggregate_to

Character string. Level of aggregation for all MARKET_CODES and gears ("QTR", "YEAR", "SEMESTER", MIX"). Default = YEAR.

borrowLengths

Boolean. Return data as is or use algorithm to borrow lengths from neighboring cells (Time and/or space)

proportionMissing

Numeric scalar. Proportion of missing samples allowed per YEAR for each MARKET_CODE/GEAR combination). Default = 0.2

otherGear

Character string. Code to indicate the class for "other Gear". This is the group of gear types that land the species of interest but in small numbers Default = "998"

outputDir

Character string. Path to output directory (png files saved here)

outputPlots

Boolean. Should plots be created. T or F (Default = F)

logfile

Character string. Specify the name for the log file generated describing all decisions made.

speciesRules

List. Containing species specific rules. Default = NULL (Fully automated). Note: Predefined speciesRules will be bundled with the package for select species

Value

List of landings and associated length samples

landings

Tibble (n x 8). Aggregated landings data. YEAR, QTR, NEGEAR, MARKET_CODE,landings_land (metric tonnes), landings_nn (# trips), len_totalNumLen (# fish lengths), len_numLengthSamples (# independent samples)

lengthData

Tibble (m x 8 ). Aggregated length data. YEAR, QTR, NEGEAR, MARKET_CODE, LENGTH (length of fish), NUMLEN (# fish at LENGTH)

Details

All plotting functions will need to be finined/generalized rmd file needs to be created to report all decisions