
Standardize trip/interview rows for interview-based workflows
Source:R/prep-interviews.R
prep_interviews_trips.RdConverts raw-ish interview records into a canonical tibble for downstream use
with add_interviews(). This helper standardizes the trip/interview unit,
computes effort from timestamps when needed, normalizes trip_status, and
emits stable columns for effort, trip duration, angler party size, and
optional interview attributes.
The returned table always contains canonical columns:
date, interview_uid, effort_hours, trip_status, trip_duration,
n_anglers, and refused. Optional columns such as catch_total,
harvest_total, angler_type, angler_method, species_sought, and any
selected strata are appended when supplied.
Usage
prep_interviews_trips(
data,
date,
interview_uid,
effort_hours = NULL,
trip_status,
trip_duration = NULL,
trip_start = NULL,
interview_time = NULL,
catch_total = NULL,
harvest_total = NULL,
angler_type = NULL,
angler_method = NULL,
species_sought = NULL,
n_anglers = NULL,
refused = NULL,
strata = NULL
)Arguments
- data
A data frame containing interview records.
- date
Tidy selector for the Date column.
- interview_uid
Tidy selector for the unique interview identifier.
- effort_hours
Optional tidy selector for an effort-in-hours column. Supply this when hours are already available directly.
- trip_status
Tidy selector for the trip-status column. Values are normalized to lowercase and must resolve to
"complete"or"incomplete".- trip_duration
Optional tidy selector for a trip duration column in hours. When omitted, the helper uses
effort_hoursif present or computes duration fromtrip_startandinterview_time.- trip_start
Optional tidy selector for trip start timestamps.
- interview_time
Optional tidy selector for interview timestamps. When
effort_hoursis omitted,trip_startandinterview_timeare used to compute effort in hours.- catch_total
Optional tidy selector for total catch per trip.
- harvest_total
Optional tidy selector for total harvest per trip.
- angler_type
Optional tidy selector for angler type (e.g.
"bank","boat").- angler_method
Optional tidy selector for fishing method.
- species_sought
Optional tidy selector for the target species field.
- n_anglers
Optional tidy selector for party size. Defaults to
1Lwhen omitted.- refused
Optional tidy selector for the refused interview flag. Defaults to
FALSEwhen omitted.- strata
Optional tidy selector for one or more strata columns to carry forward into the standardized output.
Value
A tibble with canonical trip/interview columns ready for
add_interviews().
See also
compute_effort(), add_interviews()
Other "Survey Design":
add_catch(),
add_counts(),
add_interviews(),
add_lengths(),
add_sections(),
as_creel_svydesign(),
as_hybrid_svydesign(),
compute_angler_effort(),
compute_effort(),
creel_design(),
creel_schema(),
creel_vocabulary(),
derive_angler_count(),
est_effort_camera(),
impute_camera_counts(),
mean_party_size(),
prep_counts_boat_party(),
prep_counts_daily_effort(),
prep_interview_catch(),
validate_creel_schema()
Examples
raw <- data.frame(
survey_date = as.Date(c("2024-06-01", "2024-06-02")),
day_type = c("weekend", "weekend"),
iid = c("i1", "i2"),
hours = c(2.5, 3.0),
status = c("Complete", "incomplete"),
duration = c(2.5, 3.0)
)
prep_interviews_trips(raw, date = survey_date, interview_uid = iid,
effort_hours = hours, trip_status = status,
trip_duration = duration)
#> # A tibble: 2 × 7
#> date interview_uid effort_hours trip_status trip_duration n_anglers
#> <date> <chr> <dbl> <chr> <dbl> <int>
#> 1 2024-06-01 i1 2.5 complete 2.5 1
#> 2 2024-06-02 i2 3 incomplete 3 1
#> # ℹ 1 more variable: refused <lgl>