## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4, out.width = "100%" ) ## ----load--------------------------------------------------------------------- library(tidycreel) library(ggplot2) ## ----design-no-counts--------------------------------------------------------- # Build a design from the bundled example calendar data("example_counts") cal <- unique(example_counts[, c("date", "day_type")]) design <- creel_design(cal, date = date, strata = day_type) plot_design(design, title = "Sample sizes by stratum") ## ----design-with-counts, warning = FALSE-------------------------------------- design <- add_counts(design, example_counts) plot_design(design, title = "Count distribution by stratum") ## ----schedule-plot------------------------------------------------------------ # Generate a three-month schedule sampling 40 % of days schedule <- generate_schedule( start_date = "2024-06-01", end_date = "2024-08-31", n_periods = 2, sampling_rate = 0.4, seed = 42 ) autoplot(schedule, title = "2024 Summer Creel Schedule") ## ----effort-ungrouped, warning = FALSE---------------------------------------- data("example_interviews") design <- add_interviews( design, example_interviews, catch = catch_total, effort = hours_fished, trip_status = trip_status ) effort <- estimate_effort(design) autoplot(effort, title = "Total angler-effort estimate") ## ----effort-grouped, warning = FALSE------------------------------------------ effort_by_type <- estimate_effort(design, by = day_type) autoplot(effort_by_type, title = "Angler-effort by day type") ## ----cpue, warning = FALSE---------------------------------------------------- cpue <- estimate_catch_rate(design) autoplot(cpue, title = "Walleye CPUE (catch per angler-hour)") ## ----length-dist-------------------------------------------------------------- data("example_lengths") data("example_catch") # Species catch is required to group a distribution BY species: the totals are # scaled onto the reported catch, and only this table records catch per species # (the interview-level column is the all-species total). design <- add_catch( design, example_catch, catch_uid = interview_id, interview_uid = interview_id, species = species, count = count, catch_type = catch_type ) design <- add_lengths( design, example_lengths, length_uid = interview_id, interview_uid = interview_id, species = species, length = length, length_type = length_type, count = count, release_format = "binned" ) ld <- est_length_distribution(design, by = species, bin_width = 25) autoplot(ld, theme = "creel") ## ----combine, eval = FALSE---------------------------------------------------- # # Requires patchwork # library(patchwork) # plot_design(design) + autoplot(effort) ## ----theme-arg---------------------------------------------------------------- autoplot(cpue, theme = "creel", title = "CPUE with theme = 'creel'") ## ----manual-theme------------------------------------------------------------- # Access individual colors pal <- creel_palette() pal[["primary"]] # Apply theme and colors manually ggplot(example_counts, aes(x = day_type, y = effort_hours)) + geom_boxplot(fill = pal[["light"]], color = pal[["primary"]]) + theme_creel() + labs(title = "Manual Plot with tidycreel Styles")