Skip to contents

Maps angler zip codes to county using the zipcodeR package, then counts and computes the percent of interviews by county. NA or unmappable zip codes appear as an explicit "Unknown" row.

Usage

summarize_by_county(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".

Value

A data.frame with class c("creel_summary_county", "data.frame") and columns: county (character), n (integer), pct (numeric, 1 decimal). NA or unmappable zip codes appear as "Unknown".

Details

Interview-based summary, not pressure-weighted. Requires the zipcodeR package (listed in Suggests). No state filter is applied; out-of-state anglers receive their actual county name. NA or unmappable zip codes appear as "Unknown" for data quality visibility. Sort order: "Unknown" last; remaining rows sorted by n descending.

Examples

data(example_calendar)
data(example_interviews)

# The shipped interviews carry no zip code, so add one to demonstrate the
# mapping. Two NAs are left in on purpose: an unmappable zip is reported as
# "Unknown" rather than dropped.
interviews_zip <- example_interviews
interviews_zip$zip_code <- rep(
  c("68502", "68508", NA), length.out = nrow(interviews_zip)
)

design <- creel_design(example_calendar, date = date, strata = day_type)
design <- add_interviews(design, interviews_zip,
  catch = catch_total, effort = hours_fished, harvest = catch_kept,
  trip_status = trip_status
)
#> Warning: ! No `n_anglers` provided — assuming 1 angler per interview.
#>  Pass `n_anglers = <column>` to use actual party sizes for angler-hour
#>   normalization.
#>  If the interviews really are one angler each, pass `n_anglers = 1` to state
#>   that and silence this warning.
#>  Added 22 interviews: 17 complete (77%), 5 incomplete (23%)

summarize_by_county(design)
#>             county  n  pct
#> 1 Lancaster County 15 68.2
#> 2          Unknown  7 31.8