
Preprocess camera ingress-egress timestamps
Source:R/creel-design.R
preprocess_camera_timestamps.RdConverts paired ingress and egress POSIXct timestamps into a data frame of
daily angler-effort hours, suitable for passing to add_counts.
Duration for each pair is computed as
difftime(egress_col, ingress_col, units = "hours"). Pairs where
egress precedes ingress (negative duration) are flagged with
cli_warn and excluded from the daily sum (set to
NA).
Value
A data frame with columns date and daily_effort_hours
(one row per unique date, effort hours summed across all valid pairs for
that date).
Examples
# Camera timestamps: one row per angler arrival/departure pair.
ts <- data.frame(
survey_date = rep(as.Date(c("2024-06-01", "2024-06-02")), each = 2L),
ingress_time = as.POSIXct(
c("2024-06-01 06:00:00", "2024-06-01 09:00:00",
"2024-06-02 07:00:00", "2024-06-02 10:30:00"), tz = "UTC"
),
egress_time = as.POSIXct(
c("2024-06-01 08:00:00", "2024-06-01 11:00:00",
"2024-06-02 09:00:00", "2024-06-02 13:00:00"), tz = "UTC"
)
)
preprocess_camera_timestamps(ts, date_col = "survey_date",
ingress_col = "ingress_time",
egress_col = "egress_time")
#> date daily_effort_hours
#> 1 2024-06-01 4.0
#> 2 2024-06-02 4.5