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

## ----data---------------------------------------------------------------------
library(tidycreel)

data(example_ice_sampling_frame)
data(example_ice_interviews)

head(example_ice_sampling_frame)
head(example_ice_interviews)

## ----design-------------------------------------------------------------------
design <- creel_design(
  example_ice_sampling_frame,
  date = date,
  strata = day_type,
  survey_type = "ice",
  effort_type = "time_on_ice",
  p_period = 0.5
)
print(design)

## ----design-error, error = TRUE-----------------------------------------------
try({
creel_design(
  example_ice_sampling_frame,
  date = date,
  strata = day_type,
  survey_type = "ice"
)
})

## ----interviews---------------------------------------------------------------
design <- add_interviews(
  design,
  example_ice_interviews,
  catch         = walleye_catch,
  effort        = hours_on_ice,
  harvest       = walleye_kept,
  trip_status   = trip_status,
  n_counted     = n_counted,
  n_interviewed = n_interviewed
)

## ----effort-------------------------------------------------------------------
effort_est <- estimate_effort(design)
print(effort_est)

## ----effort-active------------------------------------------------------------
design_aft <- creel_design(
  example_ice_sampling_frame,
  date        = date,
  strata      = day_type,
  survey_type = "ice",
  effort_type = "active_fishing_time",
  p_period    = 0.5
)

design_aft <- suppressMessages(add_interviews(
  design_aft,
  example_ice_interviews,
  catch         = walleye_catch,
  effort        = active_fishing_hours,
  harvest       = walleye_kept,
  trip_status   = trip_status,
  n_counted     = n_counted,
  n_interviewed = n_interviewed
))

effort_aft <- estimate_effort(design_aft)
print(effort_aft)

## ----effort-by-shelter--------------------------------------------------------
effort_by_shelter <- estimate_effort(design, by = shelter_mode)
print(effort_by_shelter)

## ----catch-rate---------------------------------------------------------------
cpue_est <- estimate_catch_rate(design)
print(cpue_est)

## ----total-catch--------------------------------------------------------------
total_catch_est <- estimate_total_catch(design)
print(total_catch_est)

