Skip to contents

Converts a long-format catch table into a canonical tibble for downstream use with add_catch(). The helper standardizes the interview linkage field, species field, numeric catch counts, and normalized catch-type values while keeping the data in long form.

The returned table always contains canonical columns: interview_uid, species, count, and catch_type.

Usage

prep_interview_catch(data, interview_uid, species, count, catch_type)

Arguments

data

A data frame in long format: one row per interview/species/catch-type combination.

interview_uid

Tidy selector for the interview linkage column.

species

Tidy selector for the species code or name column.

count

Tidy selector for the numeric catch count column.

catch_type

Tidy selector for the catch fate column. Values are normalized to lowercase.

Value

A tibble with canonical columns interview_uid, species, count, and catch_type.

Examples

raw <- data.frame(
  iid  = c("i1", "i1", "i2"),
  sp   = c("walleye", "walleye", "bass"),
  n    = c(5, 2, 1),
  fate = c("Caught", "HARVESTED", "released")
)
prep_interview_catch(raw, interview_uid = iid, species = sp,
                     count = n, catch_type = fate)
#> # A tibble: 3 × 4
#>   interview_uid species count catch_type
#>   <chr>         <chr>   <dbl> <chr>     
#> 1 i1            walleye     5 caught    
#> 2 i1            walleye     2 harvested 
#> 3 i2            bass        1 released