Skip to contents

Counts and computes the percent of interviews by angler zip code of origin. NA zip codes appear as an explicit "Unknown" row. Percent denominator is total interviews including NA rows.

Usage

summarize_by_zip(design, zip_col = "zip_code")

Arguments

design

A creel_design object with interviews attached via add_interviews.

zip_col

Name of the interview column holding the angler zip code. Defaults to "zip_code". Name whatever your source calls it – no organisation's raw field name is assumed.

Value

A data.frame with class c("creel_summary_zip", "data.frame") and columns: zip_code (character), n (integer), pct (numeric, 1 decimal). NA zip codes appear as "Unknown". Percent denominator is total interviews including NA.

Details

Interview-based summary, not pressure-weighted. NA zip codes appear as an explicit "Unknown" row for data quality visibility. Sort order: "Unknown" last; remaining rows sorted by n descending.

Examples

data(example_calendar, package = "tidycreel")
data(example_interviews, package = "tidycreel")
example_interviews$zip_code <- rep_len(
  c("68502", "68502", NA, "68508", NA),
  nrow(example_interviews)
)
d <- suppressWarnings(
  creel_design(example_calendar, date = date, strata = day_type)
)
d <- suppressWarnings(
  add_interviews(d, example_interviews,
    catch = catch_total, effort = hours_fished, harvest = catch_kept,
    trip_status = trip_status, trip_duration = trip_duration,
    angler_type = angler_type, angler_method = angler_method,
    species_sought = species_sought, n_anglers = n_anglers, refused = refused
  )
)
#>  Added 22 interviews: 17 complete (77%), 5 incomplete (23%)
summarize_by_zip(d)
#>   zip_code  n  pct
#> 1    68502 10 45.5
#> 2    68508  4 18.2
#> 3  Unknown  8 36.4