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          47     Tr Skagit Net
#> 2          31  Central OR Sport
#> 3          68        NT SPS Net
#> 4          73    Freshwater Net
#> 5          69        Tr SPS Net
#> 6           5       BC WCVI Net
#> 7          24   T G. Harbor Net
#> 8           2     SE Alaska Net
#> 9          62 NT Area 10E Sport
#> 10         55  Tr Area 6B:9 Net