Skip to contents

Computes the percentage of boats that are angler boats from raw count data, grouped by calendar month and day type. Formula: mean(angler_boats / (angler_boats + non_ang_boats)) per group. The day type column is resolved from the design's strata: a stratum named day_type when the design declares one, otherwise the first stratum column, which warns when the design declares more than one.

Usage

summarize_boat_composition(design, schema, day_type_col = NULL)

Arguments

design

A creel_design object with counts attached via add_counts.

schema

A creel_schema object with angler_boats_col and non_ang_boats_col set.

day_type_col

Name of the column holding the day type, as a single string. When NULL (the default) it is resolved from the design's strata as described above.

Value

A data.frame with class c("creel_summary_boat_composition", "data.frame") and columns: month (full month name), day_type, n_events (integer, count events that yielded a share), n_unknown_boats (integer, events excluded because a boat count was not recorded), n_nonpositive_boats (integer, events excluded because the boat total was zero or negative), pct_angler_boats (numeric, 1 decimal, NA when n_events is 0).

Details

Count-based summary, not interview-weighted. Rows where angler_boats + non_ang_boats == 0 are excluded from ratio computation.

Count events that yield no share

A count event contributes an angler-boat share only when the boats were counted and the total is positive. Both exclusions are real – an unrecorded count has no share to give, and a total of zero makes the ratio undefined while a negative one is a data error – and both used to happen with no trace that the event had occurred.

They are now counted in n_unknown_boats and n_nonpositive_boats, and the accounting closes:

n_events + n_unknown_boats + n_nonpositive_boats
  == count events in that month and day type

A month and day type whose every event was excluded keeps its row, reporting NA for pct_angler_boats rather than disappearing.

Examples

counts_df <- data.frame(
  date         = as.Date(c("2024-05-01", "2024-05-04",
                           "2024-06-01", "2024-06-08")),
  day_type     = c("weekday", "weekend", "weekday", "weekend"),
  angler_boats = c(3L, 2L, 4L, 1L),
  non_ang_boats = c(1L, 2L, 1L, 3L),
  count        = c(10L, 12L, 9L, 8L)
)
cal <- data.frame(
  date     = counts_df$date,
  day_type = counts_df$day_type
)
d <- suppressWarnings(
  creel_design(cal, date = date, strata = day_type)
)
d <- suppressWarnings(
  add_counts(d, counts_df, count_col = count)
)
s <- creel_schema(
  survey_type    = "instantaneous",
  angler_boats_col  = "angler_boats",
  non_ang_boats_col = "non_ang_boats"
)
summarize_boat_composition(d, s)
#>   month day_type n_events n_unknown_boats n_nonpositive_boats pct_angler_boats
#> 1   May  weekday        1               0                   0               75
#> 2   May  weekend        1               0                   0               50
#> 3  June  weekday        1               0                   0               80
#> 4  June  weekend        1               0                   0               25