Skip to contents

Streamlined version of using `left_join`, `rename`, and `relocate` to add human-readable text to a dataframe with fishery_id or similar columns. Automatically detects species and `fishery_id` column; user can specify species or alternative name for fishery_id column if needed.

Usage

label_fisheries(.data, species = NULL, fisheries_col = "fishery_id")

Arguments

.data

Dataframe containing `fishery_id` column (or analogous column with different name specied by `fisheries_col` argument)

species

character atomic identifying either "CHINOOK" or "COHO" (or variations of those). Defaults to `NULL`; only needed if `.data` does not have species defined as an attribute. Tables read from a fram database using `framrsquared` package automatically have appropriate species attribute.

fisheries_col

character atomic identifying the column treated as containing fishery_id values Defaults to `fishery_id`.

Value

Data frame with additional column `fishery_label`

Examples

## create example data
dat = data.frame(fishery_id = sample(1:73, size = 10, replace = TRUE))
## Add fishery label
dat |> label_fisheries(species = "CHINOOK")
#>    fishery_id     fishery_label
#> 1          45 NT Area 8-1 Sport
#> 2          23 NrT G. Harbor Net
#> 3          63   Tr Area 10E Net
#> 4          47     Tr Skagit Net
#> 5          31  Central OR Sport
#> 6          68        NT SPS Net
#> 7          73    Freshwater Net
#> 8          69        Tr SPS Net
#> 9           5       BC WCVI Net
#> 10         24   T G. Harbor Net