Skip to contents

Assigns fishery group identifiers that are used to define groupings of fishing effort which share catchability parameters. The fishery groups are defined by a look-up table (lk_definitions) that is joined to the data object using left_join. Names for each fishery group are defined in lk_names. Information relating to any previously assigned fishery groups in the data object is removed, including both fishery group IDs (id_fishery_group) and names (fishery_group).

The lookup table defining fishery groups (lk_definitions) must have the following fields:

  • id_fishery_group - a fishery group identifier (integer).

Additionally, it must not have a variable named fishery_group, which is reserved for the names of the fishery groups.

The lookup table providing the fishery group names (lk_names) must have the following fields:

  • id_fishery_group - a fishery group identifier (integer);

  • fishery_group - the fishery group name (character). The name can include spaces, but should not include punctuation characters. Additionally, the name should not include LaTeX special characters, e.g., underscores (_), ampersands (&), dollar signs ($) etc.

Each record in data should match at most one defined fishery group, and each fishery group should only have one name.

Usage

assign_fishery_groups(data, lk_definitions, lk_names, ...)

Arguments

data

object to which fishery group identifiers should be joined.

lk_definitions

a look-up table that defines fishery groups. lk_definitions must include a field for fishery group identifiers (id_fishery_group).

lk_names

a look-up table that provides a name for each fishery group. lk_names must include a field for fishery group identifiers (id_fishery_group) and fishery group names (fishery_group).

...

additional arguments to left_join.

Value

An object of class class(data) including fishery group identifiers (id_fishing_group).

Examples

library(sefraInputs)
x <- data.frame(effort = floor(runif(10, 100, 2000)), flag = sample(c("A", "B", "C"), size = 10, replace = TRUE))
y <- data.frame(id_fishery_group = c(1L, 2L, 2L), flag = c("A", "B", "C"))
z <- data.frame(id_fishery_group = 1:2, fishery_group = c("Flag A", "Flag BC"))
assign_fishery_groups(x, y, z)
#> Joining with `by = join_by(flag)`
#>    effort flag id_fishery_group
#> 1    1392    A                1
#> 2    1047    B                2
#> 3    1319    C                2
#> 4    1354    A                1
#> 5     282    B                2
#> 6    1554    B                2
#> 7    1562    C                2
#> 8    1982    B                2
#> 9    1943    A                1
#> 10    839    A                1