
Tabulate boat composition by month and day type
Source:R/creel-summaries.R
summarize_boat_composition.RdComputes 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.
Arguments
- design
A
creel_designobject with counts attached viaadd_counts.- schema
A
creel_schemaobject withangler_boats_colandnon_ang_boats_colset.- 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 typeA month and day type whose every event was excluded keeps its row, reporting
NA for pct_angler_boats rather than disappearing.
See also
Other "Reporting & Diagnostics":
adjust_nonresponse(),
check_completeness(),
compare_variance(),
flag_outliers(),
season_summary(),
standardize_species(),
summarize_by_angler_type(),
summarize_by_county(),
summarize_by_day_type(),
summarize_by_method(),
summarize_by_species_sought(),
summarize_by_trip_length(),
summarize_by_zip(),
summarize_cws_rates(),
summarize_hws_rates(),
summarize_length_freq(),
summarize_refusals(),
summarize_successful_parties(),
summarize_trips(),
summary.creel_estimates(),
tidy.creel_estimates(),
validate_creel_data(),
validate_design(),
validate_incomplete_trips(),
validation_report(),
write_estimates()
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