Add `stock_label` column to describe fisheries of dataframe
label_stocks.Rd
Streamlined version of using `left_join`, `rename`, and `relocate` to add human-readable text to a dataframe with stock_id or similar columns. Automatically detects species and `stock_id` column; user can specify species or alternative name for stock_d column if needed.
Arguments
- .data
Dataframe containing `stock_id` column (or analogous column with different name specied by `stocks_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.
- stocks_col
character atomic identifying the column treated as containing stock_id values Defaults to `stock_id`.
Examples
## create example data
dat = data.frame(stock_id = sample(1:73, size = 10, replace = TRUE))
## Add stock information
dat |> label_stocks(species = "CHINOOK")
#> stock_id stock_label
#> 1 2 Marked Nooksack/Samish Fall
#> 2 62 Marked Fraser River Early
#> 3 55 UnMarked Oregon North Coast Fall
#> 4 43 UnMarked CR Bonneville Pool Hatchery
#> 5 62 Marked Fraser River Early
#> 6 43 UnMarked CR Bonneville Pool Hatchery
#> 7 5 UnMarked Nooksack Spr Hatchery
#> 8 44 Marked CR Bonneville Pool Hatchery
#> 9 61 UnMarked Fraser River Early
#> 10 34 Marked Hood Canal Fall Year