appendMetier: Annotate metier

View source: R/metierAnnotation.R

appendMetierR Documentation

Annotate metier

Description

annotates metier to data table

Usage

appendMetier(
  data,
  metiertable,
  gearColumn,
  targetColumn = NULL,
  meshSizeColumn = NULL,
  selectivityDeviceColumn = NULL,
  selectivityDeviceMeshSizeColumn = NULL,
  metierColName = "metier"
)

Arguments

data

data.table with data to be annotated

metiertable

MetierTable with metier definitions, or object that can be read with readMetierTable

gearColumn

character() identifies the column in 'data' that encodes gear. Gear definition must match metiertable$gearcode

targetColumn

character(), optional, identifies the column in 'data' that encodes target species. Definition must match metiertable$target

meshSizeColumn

integer(), optional, identifies the column in 'data' that encodes the mesh size of the gear.

selectivityDeviceColumn

character(), optional, identifies the column in 'data' that encodes selectivitydevices mounted on gear. Definition must mathc metiertable$selectivityDevice

selectivityDeviceMeshSizeColumn

integer(), optional, identifies the column in 'data' that encodes the mesh size of any mounted selectivity device.

metierColName

character() name of the column that should be appended to 'data'

Details

Annotates data with metier, given a metier definition (MetierTable) and a selection of data-columns that idenitfies metier-defining variables. Metier names are defined by the column 'metier' in 'metiertable', and does not have to reflect the information actually used for annotation. For example, metiers of the type "OTB_DEF", indicating both gear and target assemblage, can be configured based only on gear codes.

For the metier-defining variables 'gearcode', 'target' and 'selectivityDevice' (see MetierTable), missing values are matches with missing values. That is, a metier that is defined with a missing value for 'target' will be annotated to otherwise matching data which has a missing value in the 'targetColumn'.

Value

data.table 'data' with the column 'metierColName' appended (character).

Examples

 data(metier4table)
 data(activityCensus)

 # annotate metier lvl 4 on the cencus based on gear, and compare with finer gear declaration.
 annotated <- appendMetier(activityCensus,
          metier4table,
          "gearNS",
          metierColName = "metier4")
 table(annotated$metier4)

 data(metier5table)
 # annotate metier lvl 5 on COD-catches based on only gear,
 # and compare with declarations for shrimp fisheries
 annotated <- appendMetier(activityCensus[activityCensus$species=="COD"],
          metier5table,
          "gearNS",
          metierColName = "metier5")
 annotatedShrimp <- annotated[annotated$targetFAO %in% c("PAN", "PRA"),]
 table(paste(annotatedShrimp$gearFAO, annotatedShrimp$targetFAO, sep="/"),
      annotatedShrimp$metier5)

 data(metier6table)
 # annotate metier lvl 6 on COD-catches based on gear and mesh size,
 # and compare with lvl 5 annotations from last example
 annotated <- appendMetier(activityCensus[activityCensus$species=="COD"],
          metier6table,
          "gearNS",
          meshSizeColumn = "meshSize",
          metierColName = "metier6")
 annotated <- appendMetier(annotated,
           metier5table,
           "gearNS",
           metierColName = "metier5")
 annotatedShrimp <- annotated[annotated$targetFAO %in% c("PAN", "PRA"),]
 table(annotatedShrimp$metier5, annotatedShrimp$metier6)
 

StoXProject/RstoxFDA documentation built on Nov. 12, 2024, 3:42 a.m.