## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----comparison---------------------------------------------------------------
# Ten-angler example
catch <- c(2, 0, 6, 1, 3, 4, 0, 2, 1, 5)
hours <- c(4, 1, 3, 2, 2, 4, 2, 2, 1, 3)

rom <- sum(catch) / sum(hours)
mor <- mean(catch / hours)

cat("ROM:", round(rom, 3), "fish/hr\n")
cat("MOR:", round(mor, 3), "fish/hr\n")

## ----rom_package--------------------------------------------------------------
library(tidycreel)

mini_calendar <- data.frame(
  date       = as.Date("2024-06-01"),
  day_type   = "weekday",
  open_time  = 6,
  close_time = 20
)

mini_counts <- data.frame(
  date       = as.Date("2024-06-01"),
  day_type   = "weekday",
  count_time = as.POSIXct("2024-06-01 10:00", tz = "UTC"),
  n_anglers  = 10
)

mini_interviews <- data.frame(
  date          = as.Date("2024-06-01"),
  catch_total   = c(2, 0, 6, 1, 3, 4, 0, 2, 1, 5),
  hours_fished  = c(4, 1, 3, 2, 2, 4, 2, 2, 1, 3),
  trip_status   = "complete",
  trip_duration = c(4, 1, 3, 2, 2, 4, 2, 2, 1, 3)
)

mini_design <- creel_design(mini_calendar, date = date, strata = day_type) |>
  add_counts(mini_counts) |>
  add_interviews(mini_interviews,
    catch         = catch_total,
    effort        = hours_fished,
    n_anglers     = 1, # every interview is a single angler
    trip_status   = trip_status,
    trip_duration = trip_duration
  )

# ROM estimate (default estimator for complete trips)
rom_est <- estimate_catch_rate(mini_design)
print(rom_est)

## ----total_catch--------------------------------------------------------------
data(example_calendar)
data(example_counts)
data(example_interviews)

season_design <- creel_design(example_calendar, date = date, strata = day_type) |>
  add_counts(example_counts) |>
  add_interviews(example_interviews,
    catch         = catch_total,
    effort        = hours_fished,
    n_anglers     = n_anglers,
    trip_status   = trip_status,
    trip_duration = trip_duration
  )

total <- estimate_total_catch(season_design)
print(total)

